fix: align OpenClaw task key flow
This commit is contained in:
parent
481190f7b3
commit
4f25126d4f
@ -227,7 +227,7 @@ App → Bridge → Gateway: device.pair.approve / device.pair.reject
|
|||||||
| `xworkmate.artifacts.collect-and-snapshot` | `{sessionKey, runId, artifactScope?, sinceUnixMs?, expectedArtifactDirs?}` | `{artifacts[], warnings[]}` |
|
| `xworkmate.artifacts.collect-and-snapshot` | `{sessionKey, runId, artifactScope?, sinceUnixMs?, expectedArtifactDirs?}` | `{artifacts[], warnings[]}` |
|
||||||
| `xworkmate.artifacts.list` | `{sessionKey, runId, ...}` | `{artifacts[] (不含内容), manifestMarkdown}` |
|
| `xworkmate.artifacts.list` | `{sessionKey, runId, ...}` | `{artifacts[] (不含内容), manifestMarkdown}` |
|
||||||
| `xworkmate.artifacts.read` | `{sessionKey, runId, artifactScope?, relativePath?, artifactRef?}` | `{artifacts[0], manifestMarkdown}` |
|
| `xworkmate.artifacts.read` | `{sessionKey, runId, artifactScope?, relativePath?, artifactRef?}` | `{artifacts[0], manifestMarkdown}` |
|
||||||
| `xworkmate.tasks.get` | `{sessionKey, runId}` | `{taskStatus, status, artifacts[], warnings[]}` |
|
| `xworkmate.tasks.get` | `{appThreadKey, openclawSessionKey, runId/taskId}` | `{taskStatus, status, artifacts[], warnings[]}` |
|
||||||
|
|
||||||
`expectedArtifactDirs` has a single upstream source:
|
`expectedArtifactDirs` has a single upstream source:
|
||||||
`session.start.metadata.xworkmateTaskArtifactContract.expectedArtifactDirs`.
|
`session.start.metadata.xworkmateTaskArtifactContract.expectedArtifactDirs`.
|
||||||
|
|||||||
@ -43,6 +43,7 @@ xworkmate-app
|
|||||||
│ ├─ params: sessionId, threadId, prompt, workingDirectory
|
│ ├─ params: sessionId, threadId, prompt, workingDirectory
|
||||||
│ ├─ routing: executionTarget=gateway, preferredGatewayProviderId=openclaw
|
│ ├─ routing: executionTarget=gateway, preferredGatewayProviderId=openclaw
|
||||||
│ └─ metadata: xworkmateTaskArtifactContract
|
│ └─ metadata: xworkmateTaskArtifactContract
|
||||||
|
│ └─ appThreadKey only; no prefilled openclawSessionKey
|
||||||
└─ Listen for SSE session.update events
|
└─ Listen for SSE session.update events
|
||||||
├─ status=running → poll xworkmate.tasks.get
|
├─ status=running → poll xworkmate.tasks.get
|
||||||
├─ terminal snapshot → applyGatewayChatResult()
|
├─ terminal snapshot → applyGatewayChatResult()
|
||||||
@ -198,6 +199,8 @@ now copied into tasks/<session>/<run>/artifacts/ before export.
|
|||||||
|
|
||||||
xworkmate.tasks.get:
|
xworkmate.tasks.get:
|
||||||
Bridge forwards typed lookup to the plugin/native task-registry.
|
Bridge forwards typed lookup to the plugin/native task-registry.
|
||||||
|
The request uses the persisted association:
|
||||||
|
{appThreadKey, openclawSessionKey, runId/taskId}
|
||||||
Terminal state comes from native task records only. Missing native records
|
Terminal state comes from native task records only. Missing native records
|
||||||
return structured errors such as no_native_task_record instead of inferring
|
return structured errors such as no_native_task_record instead of inferring
|
||||||
success from artifacts or reconstructing a Bridge task dictionary.
|
success from artifacts or reconstructing a Bridge task dictionary.
|
||||||
|
|||||||
@ -16,14 +16,15 @@ session identity boundary.
|
|||||||
Rules:
|
Rules:
|
||||||
|
|
||||||
- App code may keep `sessionKey` for local TaskThread and UI session APIs.
|
- App code may keep `sessionKey` for local TaskThread and UI session APIs.
|
||||||
- XWorkmate OpenClaw integration payloads must use `appThreadKey` and
|
- App `session.start` only carries `appThreadKey` in typed metadata; it does
|
||||||
`openclawSessionKey`.
|
not preemptively choose the OpenClaw native session key.
|
||||||
- Bridge may send `sessionKey` only when calling OpenClaw native APIs that
|
- Bridge resolves or reuses `openclawSessionKey`, persists the mapping, and
|
||||||
require that field, such as `chat.send`.
|
then uses that key for OpenClaw native APIs such as `chat.send`.
|
||||||
- Plugin lookup must read `appThreadKey -> openclawSessionKey` from
|
- Plugin lookup must read `appThreadKey -> openclawSessionKey` from
|
||||||
`SessionEntry.pluginExtensions`, not from string replace or reverse parsing.
|
`SessionEntry.pluginExtensions`, not from string replace or reverse parsing.
|
||||||
- Legacy `sessionKey` aliases are not accepted from App or Bridge as mapping
|
- `xworkmate.tasks.get` must be invoked with the persisted association
|
||||||
inputs.
|
(`appThreadKey`, `openclawSessionKey`, `runId/taskId`), not with a legacy
|
||||||
|
`sessionKey` alias.
|
||||||
|
|
||||||
## State Graph
|
## State Graph
|
||||||
|
|
||||||
|
|||||||
@ -328,7 +328,6 @@ class GoTaskServiceRequest {
|
|||||||
if (_usesGatewaySessionMode(acpMode)) ...<String, dynamic>{
|
if (_usesGatewaySessionMode(acpMode)) ...<String, dynamic>{
|
||||||
'executionTarget': normalizedTarget.promptValue,
|
'executionTarget': normalizedTarget.promptValue,
|
||||||
'appThreadKey': threadId,
|
'appThreadKey': threadId,
|
||||||
'openclawSessionKey': threadId,
|
|
||||||
if (agentId.trim().isNotEmpty) 'agentId': agentId.trim(),
|
if (agentId.trim().isNotEmpty) 'agentId': agentId.trim(),
|
||||||
if (metadata.isNotEmpty) 'metadata': metadata,
|
if (metadata.isNotEmpty) 'metadata': metadata,
|
||||||
},
|
},
|
||||||
|
|||||||
@ -94,6 +94,32 @@ void main() {
|
|||||||
expect(params, isNot(contains('artifactScope')));
|
expect(params, isNot(contains('artifactScope')));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test(
|
||||||
|
'gateway ACP params expose appThreadKey without preempting the OpenClaw session key',
|
||||||
|
() {
|
||||||
|
const request = GoTaskServiceRequest(
|
||||||
|
sessionId: 'draft:1780718661814229-2',
|
||||||
|
threadId: 'draft:1780718661814229-2',
|
||||||
|
target: AssistantExecutionTarget.gateway,
|
||||||
|
prompt: 'collect latest AI news',
|
||||||
|
workingDirectory: '/tmp/xworkmate-thread',
|
||||||
|
model: '',
|
||||||
|
thinking: 'low',
|
||||||
|
selectedSkills: <String>[],
|
||||||
|
inlineAttachments: <GatewayChatAttachmentPayload>[],
|
||||||
|
localAttachments: <CollaborationAttachment>[],
|
||||||
|
agentId: '',
|
||||||
|
metadata: <String, dynamic>{},
|
||||||
|
provider: SingleAgentProvider.openclaw,
|
||||||
|
);
|
||||||
|
|
||||||
|
final params = request.toExternalAcpParams();
|
||||||
|
|
||||||
|
expect(params['appThreadKey'], 'draft:1780718661814229-2');
|
||||||
|
expect(params, isNot(contains('openclawSessionKey')));
|
||||||
|
},
|
||||||
|
);
|
||||||
|
|
||||||
test('recognizes openclaw as the canonical gateway provider', () {
|
test('recognizes openclaw as the canonical gateway provider', () {
|
||||||
final provider = SingleAgentProvider.fromJsonValue('openclaw');
|
final provider = SingleAgentProvider.fromJsonValue('openclaw');
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user