@astrosheep/keiyaku 4.6.21 → 4.6.23

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.
@@ -1,7 +1,11 @@
1
1
  # Keiyaku in Pi
2
2
 
3
3
  The existing Pi package entry `plugins/pi/keiyaku.ts` supplies `/keiyaku` (the
4
- status overlay) and ten native Akuma tools. It imports only the supported
4
+ status overlay). The ten native Akuma tools are temporarily registered with
5
+ Pi's `hidden` exposure while their design is unfinished: they are not declared
6
+ to the model, discoverable, or callable, even if selected explicitly. The CLI
7
+ and `/keiyaku` command remain available. The implementation is retained for
8
+ development. It imports only the supported
5
9
  `@astrosheep/keiyaku` package root. Build the checkout before loading it locally;
6
10
  an installed npm package already carries its built SDK.
7
11
 
@@ -104,8 +108,9 @@ npm run build
104
108
  npm test -- tests/akuma-in-process.test.ts tests/pi-akuma-tools.test.ts tests/pi-extension.test.ts tests/package-consumers.test.ts
105
109
  ```
106
110
 
107
- The native-tool tests load the built package's actual extension with Pi's public
108
- loader and execute a deterministic offline model through real Pi tool calls,
111
+ The native-tool tests verify that the built package's default extension keeps
112
+ the tools hidden. An explicit development fixture registers the same implementation
113
+ with direct exposure and executes a deterministic offline model through real Pi tool calls,
109
114
  SDK operations, Heart/leash, subprocess tools and detached launches. They do not
110
115
  replace the Body engine or depend on model credentials. These are not real-model
111
116
  quality or OS sandbox tests.
@@ -59,7 +59,7 @@ function caller(ctx: ExtensionContext): AkumaCaller {
59
59
  }
60
60
 
61
61
  /** Native adaptation only. Addressing, admission, observation and lifecycle stay with Keiyaku. */
62
- export function registerAkumaTools(pi: ExtensionAPI): void {
62
+ export function registerAkumaTools(pi: ExtensionAPI, exposure: "hidden" | "direct" = "hidden"): void {
63
63
  pi.registerFlag("keiyaku-request-only", {
64
64
  type: "boolean",
65
65
  default: false,
@@ -110,6 +110,7 @@ export function registerAkumaTools(pi: ExtensionAPI): void {
110
110
  pi.registerTool({
111
111
  name,
112
112
  label: name,
113
+ exposure,
113
114
  description,
114
115
  parameters: { type: "object", properties, required, additionalProperties: false },
115
116
  outputSchema: { type: "object", additionalProperties: true },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@astrosheep/keiyaku",
3
- "version": "4.6.21",
3
+ "version": "4.6.23",
4
4
  "workspaces": [
5
5
  "plugins/square",
6
6
  "plugins/paseo/forwarder"
@@ -81,8 +81,8 @@
81
81
  "dependencies": {
82
82
  "@agentclientprotocol/sdk": "^1.3.0",
83
83
  "@anthropic-ai/claude-agent-sdk": "^0.3.226",
84
- "@astrosheep/keiyaku-plugin-square": "0.1.15",
85
- "@astrosheep/square": "^0.3.98",
84
+ "@astrosheep/keiyaku-plugin-square": "0.1.17",
85
+ "@astrosheep/square": "^0.3.104",
86
86
  "@getpaseo/client": "0.11.2",
87
87
  "@getpaseo/protocol": "0.11.2",
88
88
  "@opencode/client": "2.0.20",
@@ -15,8 +15,10 @@ const call = z.discriminatedUnion("kind", [
15
15
  })) }),
16
16
  z.object({ kind: z.literal("other"), display: z.string(), input: input.optional() }),
17
17
  ]);
18
- const row = z.union([
18
+ const knownRow = z.union([
19
19
  base.extend({ kind: z.literal("turn"), ...turnFields, bodySequence: count.optional() }),
20
+ base.extend({ kind: z.literal("report"), ...turnFields, bodySequence: count, text: z.string(),
21
+ truncated: z.literal(true).optional() }),
20
22
  base.extend({ kind: z.literal("tell"), tellId: z.string(), text: z.string(), state: z.enum(["pending", "told"]),
21
23
  deliveries: z.array(z.object({ deliveredAt: z.string(), route: z.enum(["launch", "live"]),
22
24
  turnSequence: count, receipt: z.enum(["unavailable", "required"]).optional() })).optional() }),
@@ -33,6 +35,15 @@ const row = z.union([
33
35
  base.extend({ kind: z.enum(["said", "thought", "note", "call"]), ...turnFields, text: z.string(),
34
36
  truncated: z.literal(true).optional() }),
35
37
  ]);
38
+ // Identity is the trust boundary. Never copy a rejected payload into the mirror.
39
+ const identity = z.object({ kind: z.string().min(1), sequence: z.number().int().positive().safe(),
40
+ at: z.string().refine((value) => Number.isFinite(Date.parse(value))) }).passthrough();
41
+ const row = identity.transform((value) => {
42
+ const decoded = knownRow.safeParse(value);
43
+ if (decoded.success) return decoded.data;
44
+ return { kind: "adapter-diagnostic" as const, sequence: value.sequence, at: value.at,
45
+ recordKind: value.kind.slice(0, 80).replace(/[^a-zA-Z0-9_.-]/gu, "?") };
46
+ });
36
47
  export const historySchema = z.object({ rows: z.array(row), omitted: count,
37
48
  hasEarlier: z.boolean(), hasLater: z.boolean(), historyLost: z.boolean(),
38
49
  lowestRetained: count.nullable(), highest: count.nullable() });
@@ -18,6 +18,10 @@ export function createMirror(sessionId: string, emit: Emit) {
18
18
  const item = (value: ProviderTimelineItem, timestamp?: string) => emit({
19
19
  type: "timeline.item", sessionId, item: value, ...(timestamp === undefined ? {} : { timestamp }),
20
20
  });
21
+ const observationWarning = (row: Extract<Row, { kind: "adapter-diagnostic" }>) => {
22
+ item({ type: "notification", id: `keiyaku:observation/${row.sequence}`, level: "warning",
23
+ message: `Observation incomplete: unsupported or malformed ${row.recordKind} record at sequence ${row.sequence}.` }, row.at);
24
+ };
21
25
  const finish = (target: Turn | undefined, state: "completed" | "failed" | "canceled", message?: string) => {
22
26
  if (!target || target.closed) return;
23
27
  target.closed = true;
@@ -36,7 +40,10 @@ export function createMirror(sessionId: string, emit: Emit) {
36
40
  const { rows } = history;
37
41
  covered = { high: history.highest ?? 0,
38
42
  signatures: new Map(rows.map((row) => [row.sequence, JSON.stringify(row)])) };
39
- for (const row of rows) if (row.kind === "tell") displayedTells.set(row.tellId, row.sequence);
43
+ for (const row of rows) {
44
+ if (row.kind === "tell") displayedTells.set(row.tellId, row.sequence);
45
+ else if (row.kind === "adapter-diagnostic") observationWarning(row);
46
+ }
40
47
  const latest = rows.filter((row) => row.kind === "turn").sort((a, b) => a.sequence - b.sequence).at(-1);
41
48
  if (latest?.kind === "turn") {
42
49
  turn = { sequence: latest.turnSequence,
@@ -167,6 +174,11 @@ export function createMirror(sessionId: string, emit: Emit) {
167
174
  item({ type: "assistant_message", id: `keiyaku:said/${row.sequence}`, text: row.text }, row.at);
168
175
  } else if (row.kind === "thought") {
169
176
  item({ type: "reasoning", id: `keiyaku:thought/${row.sequence}`, text: row.text }, row.at);
177
+ } else if (row.kind === "adapter-diagnostic") {
178
+ observationWarning(row);
179
+ } else if (row.kind === "report") {
180
+ item({ type: "notification", id: `keiyaku:report/${row.sequence}`, level: "info",
181
+ message: `Progress report: ${row.text}` }, row.at);
170
182
  } else if (row.kind === "note") {
171
183
  item({ type: "notification", id: `keiyaku:note/${row.sequence}`, level: "info", message: row.text }, row.at);
172
184
  } else if (row.kind === "outcome") {
@@ -1,7 +1,11 @@
1
1
  # Keiyaku in Pi
2
2
 
3
3
  The existing Pi package entry `plugins/pi/keiyaku.ts` supplies `/keiyaku` (the
4
- status overlay) and ten native Akuma tools. It imports only the supported
4
+ status overlay). The ten native Akuma tools are temporarily registered with
5
+ Pi's `hidden` exposure while their design is unfinished: they are not declared
6
+ to the model, discoverable, or callable, even if selected explicitly. The CLI
7
+ and `/keiyaku` command remain available. The implementation is retained for
8
+ development. It imports only the supported
5
9
  `@astrosheep/keiyaku` package root. Build the checkout before loading it locally;
6
10
  an installed npm package already carries its built SDK.
7
11
 
@@ -104,8 +108,9 @@ npm run build
104
108
  npm test -- tests/akuma-in-process.test.ts tests/pi-akuma-tools.test.ts tests/pi-extension.test.ts tests/package-consumers.test.ts
105
109
  ```
106
110
 
107
- The native-tool tests load the built package's actual extension with Pi's public
108
- loader and execute a deterministic offline model through real Pi tool calls,
111
+ The native-tool tests verify that the built package's default extension keeps
112
+ the tools hidden. An explicit development fixture registers the same implementation
113
+ with direct exposure and executes a deterministic offline model through real Pi tool calls,
109
114
  SDK operations, Heart/leash, subprocess tools and detached launches. They do not
110
115
  replace the Body engine or depend on model credentials. These are not real-model
111
116
  quality or OS sandbox tests.
@@ -59,7 +59,7 @@ function caller(ctx: ExtensionContext): AkumaCaller {
59
59
  }
60
60
 
61
61
  /** Native adaptation only. Addressing, admission, observation and lifecycle stay with Keiyaku. */
62
- export function registerAkumaTools(pi: ExtensionAPI): void {
62
+ export function registerAkumaTools(pi: ExtensionAPI, exposure: "hidden" | "direct" = "hidden"): void {
63
63
  pi.registerFlag("keiyaku-request-only", {
64
64
  type: "boolean",
65
65
  default: false,
@@ -110,6 +110,7 @@ export function registerAkumaTools(pi: ExtensionAPI): void {
110
110
  pi.registerTool({
111
111
  name,
112
112
  label: name,
113
+ exposure,
113
114
  description,
114
115
  parameters: { type: "object", properties, required, additionalProperties: false },
115
116
  outputSchema: { type: "object", additionalProperties: true },