@coda-console/protocol 1.7.0 → 1.9.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +34 -3
- package/agent.mjs +84 -0
- package/docs/agent-protocol.md +62 -1
- package/package.json +4 -2
- package/schemas/agent/agent-capabilities.json +29 -0
- package/schemas/agent/client-capabilities.json +24 -0
- package/schemas/agent/compact.json +46 -0
- package/schemas/agent/default.json +12 -0
- package/schemas/agent/failure.json +51 -0
- package/schemas/agent/json.json +7 -0
- package/schemas/agent/messages.json +40 -0
- package/schemas/agent/remote-code.json +50 -0
- package/schemas/agent/remote.json +37 -0
- package/schemas/agent/review.json +38 -0
- package/schemas/agent/steering.json +83 -0
- package/schemas/agent/usage.json +13 -0
- package/schemas/agent/wait-stop.json +28 -0
- package/schemas/agent/wait.json +99 -0
- package/workflow/dialect.json +1 -0
- package/workflow/keywords.mjs +1 -1
- package/workflow/structure.json +920 -0
- package/workflow/structure.mjs +256 -0
- package/workflow.mjs +10 -5
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://coda.pub/schemas/agent/v1/review.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"description": "审核须为对象",
|
|
6
|
+
"properties": {
|
|
7
|
+
"state": {
|
|
8
|
+
"enum": [
|
|
9
|
+
"reviewing",
|
|
10
|
+
"approved",
|
|
11
|
+
"denied"
|
|
12
|
+
],
|
|
13
|
+
"description": "state 只能是 reviewing、approved、denied"
|
|
14
|
+
},
|
|
15
|
+
"reason": {
|
|
16
|
+
"type": "string",
|
|
17
|
+
"description": "reason 须为不超过 4000 字的文本",
|
|
18
|
+
"x-length": 4000
|
|
19
|
+
},
|
|
20
|
+
"risk": {
|
|
21
|
+
"description": "不认识的 risk 不记;不因此丢弃审核。已知值见 $defs/risk。"
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
"required": [
|
|
25
|
+
"state"
|
|
26
|
+
],
|
|
27
|
+
"$defs": {
|
|
28
|
+
"risk": {
|
|
29
|
+
"enum": [
|
|
30
|
+
"low",
|
|
31
|
+
"medium",
|
|
32
|
+
"high",
|
|
33
|
+
"critical"
|
|
34
|
+
],
|
|
35
|
+
"description": "risk 只能是 low、medium、high 或 critical"
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
@@ -0,0 +1,83 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://coda.pub/schemas/agent/v1/steering.json",
|
|
4
|
+
"description": "生态的 _session/steering 扩展中 Coda 使用的部分;prompt 的内容块仍交 ACP SDK 校验。",
|
|
5
|
+
"$defs": {
|
|
6
|
+
"capabilities": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"description": "initialize 的 _meta 须为对象",
|
|
9
|
+
"properties": {
|
|
10
|
+
"steering": {
|
|
11
|
+
"type": "object",
|
|
12
|
+
"description": "steering 须为对象",
|
|
13
|
+
"properties": {
|
|
14
|
+
"supported": {
|
|
15
|
+
"type": "boolean",
|
|
16
|
+
"description": "supported 须为 true 或 false"
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"params": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"description": "插话参数须为对象",
|
|
25
|
+
"properties": {
|
|
26
|
+
"sessionId": {
|
|
27
|
+
"type": "string",
|
|
28
|
+
"description": "缺 sessionId",
|
|
29
|
+
"minLength": 1
|
|
30
|
+
},
|
|
31
|
+
"prompt": {
|
|
32
|
+
"description": "与 session/prompt 相同,由 ACP SDK 校验;Coda 发一个文本块"
|
|
33
|
+
},
|
|
34
|
+
"_meta": {
|
|
35
|
+
"type": "object",
|
|
36
|
+
"description": "_meta 须为对象",
|
|
37
|
+
"properties": {
|
|
38
|
+
"steering": {
|
|
39
|
+
"type": "object",
|
|
40
|
+
"description": "steering 须为对象",
|
|
41
|
+
"properties": {
|
|
42
|
+
"idleBehavior": {
|
|
43
|
+
"const": "promptRequired",
|
|
44
|
+
"description": "idleBehavior 须为 promptRequired"
|
|
45
|
+
}
|
|
46
|
+
},
|
|
47
|
+
"required": [
|
|
48
|
+
"idleBehavior"
|
|
49
|
+
]
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"required": [
|
|
53
|
+
"steering"
|
|
54
|
+
]
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
"required": [
|
|
58
|
+
"sessionId",
|
|
59
|
+
"prompt",
|
|
60
|
+
"_meta"
|
|
61
|
+
]
|
|
62
|
+
},
|
|
63
|
+
"result": {
|
|
64
|
+
"type": "object",
|
|
65
|
+
"description": "插话答复须为对象",
|
|
66
|
+
"properties": {
|
|
67
|
+
"outcome": {
|
|
68
|
+
"enum": [
|
|
69
|
+
"injected",
|
|
70
|
+
"promptRequired"
|
|
71
|
+
],
|
|
72
|
+
"description": "插话须回答 injected 或 promptRequired;其他结果的投递状态未知"
|
|
73
|
+
},
|
|
74
|
+
"reason": {
|
|
75
|
+
"description": "原因由 Agent 给出,Coda 只按 outcome 判断投递结果"
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"required": [
|
|
79
|
+
"outcome"
|
|
80
|
+
]
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://coda.pub/schemas/agent/v1/usage.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"description": "须为不超过 4096 字节的 JSON 对象",
|
|
6
|
+
"x-json": {
|
|
7
|
+
"schema": {
|
|
8
|
+
"type": "object",
|
|
9
|
+
"description": "须为不超过 4096 字节的 JSON 对象"
|
|
10
|
+
},
|
|
11
|
+
"maxBytes": 4096
|
|
12
|
+
}
|
|
13
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://coda.pub/schemas/agent/v1/wait-stop.json",
|
|
4
|
+
"description": "停止一项活动;答复只表示收到,是否已停止由之后的活动报告确认。",
|
|
5
|
+
"$defs": {
|
|
6
|
+
"params": {
|
|
7
|
+
"type": "object",
|
|
8
|
+
"description": "params 须为对象",
|
|
9
|
+
"properties": {
|
|
10
|
+
"sessionId": {
|
|
11
|
+
"$ref": "wait.json#/properties/sessionId"
|
|
12
|
+
},
|
|
13
|
+
"waitId": {
|
|
14
|
+
"$ref": "wait.json#/properties/waitId"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
"required": [
|
|
18
|
+
"sessionId",
|
|
19
|
+
"waitId"
|
|
20
|
+
]
|
|
21
|
+
},
|
|
22
|
+
"result": {
|
|
23
|
+
"type": "object",
|
|
24
|
+
"description": "Agent 回 {};回复只表示收到",
|
|
25
|
+
"properties": {}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "https://json-schema.org/draft/2020-12/schema",
|
|
3
|
+
"$id": "https://coda.pub/schemas/agent/v1/wait.json",
|
|
4
|
+
"type": "object",
|
|
5
|
+
"description": "params 须为对象",
|
|
6
|
+
"properties": {
|
|
7
|
+
"sessionId": {
|
|
8
|
+
"allOf": [
|
|
9
|
+
{
|
|
10
|
+
"type": "string",
|
|
11
|
+
"description": "缺 sessionId",
|
|
12
|
+
"minLength": 1
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
"type": "string",
|
|
16
|
+
"description": "sessionId 须为不超过 200 字的文本",
|
|
17
|
+
"x-length": 200
|
|
18
|
+
}
|
|
19
|
+
]
|
|
20
|
+
},
|
|
21
|
+
"waitId": {
|
|
22
|
+
"allOf": [
|
|
23
|
+
{
|
|
24
|
+
"type": "string",
|
|
25
|
+
"description": "缺 waitId",
|
|
26
|
+
"minLength": 1
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"type": "string",
|
|
30
|
+
"description": "waitId 须为不超过 200 字的文本",
|
|
31
|
+
"x-length": 200
|
|
32
|
+
}
|
|
33
|
+
]
|
|
34
|
+
},
|
|
35
|
+
"state": {
|
|
36
|
+
"enum": [
|
|
37
|
+
"waiting",
|
|
38
|
+
"handling",
|
|
39
|
+
"done",
|
|
40
|
+
"failed",
|
|
41
|
+
"cancelled"
|
|
42
|
+
],
|
|
43
|
+
"description": "state 只能是 waiting、handling、done、failed、cancelled"
|
|
44
|
+
},
|
|
45
|
+
"kind": {
|
|
46
|
+
"type": "string",
|
|
47
|
+
"description": "kind 须为不超过 50 字的文本",
|
|
48
|
+
"x-length": 50
|
|
49
|
+
},
|
|
50
|
+
"title": {
|
|
51
|
+
"type": "string",
|
|
52
|
+
"description": "title 须为不超过 500 字的文本",
|
|
53
|
+
"x-length": 500
|
|
54
|
+
},
|
|
55
|
+
"detail": {
|
|
56
|
+
"type": "string",
|
|
57
|
+
"description": "detail 须为不超过 4000 字的文本",
|
|
58
|
+
"x-length": 4000
|
|
59
|
+
},
|
|
60
|
+
"childSessionId": {
|
|
61
|
+
"type": "string",
|
|
62
|
+
"description": "childSessionId 须为不超过 200 字的文本",
|
|
63
|
+
"x-length": 200
|
|
64
|
+
},
|
|
65
|
+
"model": {
|
|
66
|
+
"type": "string",
|
|
67
|
+
"description": "model 须为不超过 200 字的文本",
|
|
68
|
+
"x-length": 200
|
|
69
|
+
},
|
|
70
|
+
"outputFile": {
|
|
71
|
+
"type": "string",
|
|
72
|
+
"description": "outputFile 须为不超过 4096 字的文本",
|
|
73
|
+
"x-length": 4096
|
|
74
|
+
},
|
|
75
|
+
"toolCallId": {
|
|
76
|
+
"type": "string",
|
|
77
|
+
"description": "toolCallId 须为不超过 200 字的文本",
|
|
78
|
+
"x-length": 200
|
|
79
|
+
},
|
|
80
|
+
"stoppable": {
|
|
81
|
+
"type": "boolean",
|
|
82
|
+
"description": "stoppable 须为 true 或 false"
|
|
83
|
+
},
|
|
84
|
+
"recurring": {
|
|
85
|
+
"type": "boolean",
|
|
86
|
+
"description": "recurring 须为 true 或 false"
|
|
87
|
+
},
|
|
88
|
+
"at": {
|
|
89
|
+
"type": "string",
|
|
90
|
+
"description": "at 读不出时间",
|
|
91
|
+
"format": "date-parse"
|
|
92
|
+
}
|
|
93
|
+
},
|
|
94
|
+
"required": [
|
|
95
|
+
"sessionId",
|
|
96
|
+
"waitId",
|
|
97
|
+
"state"
|
|
98
|
+
]
|
|
99
|
+
}
|
package/workflow/dialect.json
CHANGED
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
"workflow.dispatch": "手动发起(workflow_run、客户端的按钮):由事件启动的流程也订阅它,才能手动发起",
|
|
15
15
|
"workflow.cancel": "要它停下:在等它的运行被告知,走到自己的结束,以取消结束"
|
|
16
16
|
},
|
|
17
|
+
"eventRoles": {"lifecycleStart": "session.opened", "lifecycleFacts": "session.facts", "dispatch": "workflow.dispatch", "cancel": "workflow.cancel"},
|
|
17
18
|
"userMessage": "^user\\.[a-z][a-z0-9-]{0,39}$",
|
|
18
19
|
"stepFailed": "STEP_FAILED",
|
|
19
20
|
"variables": ["inputs", "run", "github", "vars"],
|
package/workflow/keywords.mjs
CHANGED
|
@@ -5,7 +5,7 @@ import { isAbsolute } from 'node:path';
|
|
|
5
5
|
|
|
6
6
|
// The byte length of a JSON value, without recursion or serializing the whole object. Stop as soon as the budget is
|
|
7
7
|
// exceeded. Only JSON values count: cycles, non-finite numbers and non-JSON objects cannot turn into a different value.
|
|
8
|
-
function jsonFits(value, max) {
|
|
8
|
+
export function jsonFits(value, max) {
|
|
9
9
|
let bytes = 0;
|
|
10
10
|
const active = new Set(), stack = [{ value }];
|
|
11
11
|
while (stack.length && bytes <= max) {
|