@coda-console/plugin-check 0.5.21 → 0.5.22

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.
@@ -125,7 +125,7 @@ export function childSpawn(value) {
125
125
  object(value, 'spawn');
126
126
  keys(value, ['turn', 'requestId', 'agent', 'prompt', 'title', 'model', 'effort', 'mode', 'options', 'checkout', 'project']);
127
127
  check([undefined, 'shared', 'worktree'].includes(value.checkout), 'invalid_input', 'checkout 必须是 shared 或 worktree');
128
- check(typeof value.agent === 'string' && AGENT_ID.test(value.agent), 'invalid_input', 'agent 须为 Agent 的 ID(agents 工具列出的)');
128
+ check(typeof value.agent === 'string' && AGENT_ID.test(value.agent), 'invalid_input', 'agent 须为 Agent 的 ID(agents 工具列出的),或用户给的 Agent 引用 coda://agents/…');
129
129
  const prompt = text(value.prompt, 'prompt', 100_000);
130
130
  return { turn: text(value.turn, 'turn', 100), requestId: text(value.requestId, 'requestId', 100), agent: value.agent, prompt,
131
131
  title: text(value.title ?? prompt.trim().slice(0, 80), 'title'), checkout: value.checkout ?? 'shared',
@@ -133,11 +133,11 @@ export function childSpawn(value) {
133
133
  settings: settings(Object.fromEntries(['model', 'effort', 'mode', 'options'].filter(k => value[k] !== undefined).map(k => [k, value[k]]))) };
134
134
  }
135
135
 
136
- // A remote client asks the user to open a root session. No checkout or parent is supplied by the agent.
136
+ // A remote client asks the user to open a root session: in the project's own directory (`checkout` shared, the default) or
137
+ // in a new worktree of its default branch (`worktree`). No parent is supplied by the agent.
137
138
  export function newSession(value) {
138
139
  object(value, 'new_session');
139
- keys(value, ['turn', 'requestId', 'project', 'agent', 'prompt', 'title', 'model', 'effort', 'mode', 'options']);
140
+ keys(value, ['turn', 'requestId', 'project', 'agent', 'prompt', 'title', 'model', 'effort', 'mode', 'options', 'checkout']);
140
141
  text(value.project, 'project', 200);
141
- const { checkout: _, ...spec } = childSpawn(value);
142
- return spec;
142
+ return childSpawn(value);
143
143
  }
@@ -1,9 +1,9 @@
1
1
  {
2
- "commit": "24631031f629cae0f395ec7c04ede6a036d49f5a",
2
+ "commit": "b4280e88dedb17190fd84e3d0678bd5b838214c2",
3
3
  "packages": {
4
4
  "@0dep/piso": "5.2.0",
5
5
  "@agentclientprotocol/sdk": "1.4.0",
6
- "@coda-console/protocol": "1.7.0",
6
+ "@coda-console/protocol": "1.9.0",
7
7
  "yaml": "2.9.1"
8
8
  },
9
9
  "files": {
@@ -13,13 +13,13 @@
13
13
  "check/coda/components/plugins/plugin-source-rules.mjs": "d894d55a3272df5ef3b108b68820c64aefdf6b69346404b58954f2a3503cb4a5",
14
14
  "check/coda/components/plugins/skill-document.mjs": "c5b5e815c42cd836572f7b60e22a46af6ac607fd9df0170fa36f955825636ce6",
15
15
  "check/coda/components/prompt-recovery/prompt-recovery.mjs": "f43f21d24c19a58113d3304f9248225b12080ab00ed15eab74bf7b94642732de",
16
- "check/coda/components/session-config/commands.mjs": "be07377c153f812a648deb60f023269c1f0a49b91cf2e4516f05b7eac09c28de",
16
+ "check/coda/components/session-config/commands.mjs": "5d6139f1e5814422dab5f9d69f0b31967bf08f49c51c40ff91d9282dfc642dd9",
17
17
  "check/coda/components/workflows/executor-labels.mjs": "dceca6ae60c0a4f3c3cc72a6c84f1489831790774c93caab96e4ddb493bc89e1",
18
- "check/coda/domain/agent-protocol.mjs": "09243f47df4112d6484b05d6baeb646d9b511b5e21ee58a3f65803b177d5232e",
18
+ "check/coda/domain/agent-protocol.mjs": "769cc10dc21b3cef7718f94272aaef2d17d4882d42617b408cb47357abfc3bcb",
19
19
  "check/coda/domain/duration.mjs": "15dd64ef9b02342ad521c66e5968a569432a89dc7568d11afd3e6f3fe37e104b",
20
20
  "check/coda/domain/errors.mjs": "ddc00aef9bb6f9a56845a9926c82200628a906230d31212d88fcde48e36dfd36",
21
21
  "check/coda/domain/values.mjs": "01cc72b8d9c09e3fe16c93ec332ca01148bba859b1c672586d9d07444d7816c4",
22
- "check/coda/kernel/agent-failures.mjs": "e435b9a1710b8a7c0ee243f04a556464f50b1a5605fb7bb59af21b78fca1b637",
22
+ "check/coda/kernel/agent-failures.mjs": "cbc215e2403d86f0acc765c2077197e0b529fc01e213db465c388361238ea8ce",
23
23
  "check/coda/resources/plugins/resources/panels/command.mjs": "606f28bf87f87dded9df2db892bc7624c770d795ffab88f2409998346920ae42",
24
24
  "check/coda/resources/plugins/resources/panels/panels.mjs": "9e25cfbc16ed9f68101fc7bfc34b8056c13a29d2368c5561e65e333233eb921e",
25
25
  "check/coda/resources/plugins/resources/panels/rules.mjs": "8418ed83b796f18047c154d8dea8dca7d98244af8ddfe3ddf188520c59324ee8",
@@ -1,3 +1,5 @@
1
+ import { AGENT_SCHEMAS, agentMessageProblem, agentValueProblem } from '@coda-console/protocol/agent';
2
+
1
3
  // What Coda says to an agent and takes from it beside the connection itself (coda-protocol docs/agent-protocol.md): the capabilities it
2
4
  // sends, session instructions, steering, the agent's own waits, and how long Coda waits on it. Part of the plugin contract
3
5
  // coda-plugins' check is given as written (scripts/plugin-contract.mjs).
@@ -33,21 +35,13 @@ export const steeringParams = (sessionId, text) => ({ sessionId, prompt: [{ type
33
35
  export const currentModel = session => session?.configOptions?.find?.(x => x?.category === 'model')?.currentValue ?? session?.models?.currentModelId;
34
36
 
35
37
  // What an agent may say of a wait of its own (「_coda/wait」); anything else is dropped unread.
36
- const record = value => value && typeof value === 'object' && !Array.isArray(value);
37
- export const WAIT_STATES = new Set(['waiting', 'handling', 'done', 'failed', 'cancelled']);
38
- const fits = (value, limit) => value === undefined || (typeof value === 'string' && value.length <= limit);
39
- export const validWait = p => record(p) && typeof p.sessionId === 'string' && p.sessionId.length > 0 && p.sessionId.length <= 200
40
- && typeof p.waitId === 'string' && p.waitId.length > 0 && p.waitId.length <= 200 && WAIT_STATES.has(p.state)
41
- && fits(p.kind, 50) && fits(p.title, 500) && fits(p.detail, 4000) && fits(p.childSessionId, 200) && fits(p.model, 200) && fits(p.outputFile, 4096)
42
- && fits(p.toolCallId, 200)
43
- && [p.stoppable, p.recurring].every(flag => flag === undefined || typeof flag === 'boolean')
44
- && (p.at === undefined || (typeof p.at === 'string' && Number.isFinite(Date.parse(p.at))));
38
+ export const WAIT_STATES = new Set(AGENT_SCHEMAS['wait.json'].properties.state.enum);
39
+ export const validWait = p => agentMessageProblem('_coda/wait', p) === null;
45
40
  // What the agent's own check of a tool call said before running it (「工具调用的审核」): `_meta.coda.review` of the call's
46
41
  // `tool_call` or `tool_call_update`, as Coda keeps it; null for anything else. A risk it does not know is left out.
47
- const REVIEW_STATES = new Set(['reviewing', 'approved', 'denied']);
48
- const RISKS = new Set(['low', 'medium', 'high', 'critical']);
49
- export const toolReview = r => record(r) && REVIEW_STATES.has(r.state) && fits(r.reason, 4000)
50
- ? { state: r.state, ...(r.reason ? { reason: r.reason } : {}), ...(RISKS.has(r.risk) ? { risk: r.risk } : {}) } : null;
42
+ export const toolReview = r => agentValueProblem('review.json', r) === null
43
+ ? { state: r.state, ...(r.reason ? { reason: r.reason } : {}),
44
+ ...(agentValueProblem('review.json#/$defs/risk', r.risk) === null ? { risk: r.risk } : {}) } : null;
51
45
 
52
46
  // Opening a session (initialize, then session/new or session/load) may take this long.
53
47
  export const OPEN_LIMIT = 60_000;
@@ -1,12 +1,9 @@
1
- const record = value => value && typeof value === 'object' && !Array.isArray(value);
1
+ import { agentValueProblem } from '@coda-console/protocol/agent';
2
2
 
3
3
  // Only the shared protocol establishes a category; provider codes and error text stay with the plugin.
4
4
  export function agentFailure(error) {
5
5
  const failure = error?.data?._meta?.coda?.failure;
6
- if (!record(failure)) return null;
7
- return failure.kind === 'quota_exhausted' ||
8
- (failure.kind === 'service_unavailable' && ['accepted', 'not_accepted'].includes(failure.input) &&
9
- (failure.retryAfterMs === undefined || (Number.isFinite(failure.retryAfterMs) && failure.retryAfterMs >= 0))) ? failure : null;
6
+ return agentValueProblem('failure.json', failure) === null ? failure : null;
10
7
  }
11
8
 
12
9
  export function agentErrorMessage(error) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@coda-console/plugin-check",
3
- "version": "0.5.21",
3
+ "version": "0.5.22",
4
4
  "description": "Coda 插件的契约检查:扮演 Coda 读清单、启动 Agent 讲 ACP 与 _coda/wait、读面板。",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -24,7 +24,7 @@
24
24
  "dependencies": {
25
25
  "@0dep/piso": "5.2.0",
26
26
  "@agentclientprotocol/sdk": "1.4.0",
27
- "@coda-console/protocol": "1.7.0",
27
+ "@coda-console/protocol": "1.9.0",
28
28
  "ajv": "8.20.0",
29
29
  "yaml": "2.9.1"
30
30
  },