@asterism-app/builtin-api 0.22.0 → 0.23.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/docs/agents.md +4 -0
- package/docs/resource-creation.md +2 -0
- package/package.json +1 -1
- package/src/agent.ts +3 -1
- package/src/records.ts +20 -1
- package/src/tools.ts +7 -1
package/docs/agents.md
CHANGED
|
@@ -97,6 +97,10 @@ Declare an Agent preparer to filter skills or remove, change, and append instruc
|
|
|
97
97
|
|
|
98
98
|
## Extend presentation
|
|
99
99
|
|
|
100
|
+
Agent history includes immutable model blocks and tool operations. Complete tool inputs are published before execution and their results fill the same record once. Read both through the public execution decoder when building a history projection; operation completion updates the existing record rather than appending a new tool position.
|
|
101
|
+
|
|
102
|
+
Response termination metadata may describe generation failure or cancellation as well as success. It belongs to the response's last model-ordinal block and does not invalidate all earlier content. Errors before any output remain transient. Retry activity belongs to current execution state, not historical notices.
|
|
103
|
+
|
|
100
104
|
Register Agent UI extensions during frontend preparation and bind registration to its cancellation signal. Extensions can present controls, supplemental content, overlays, or modal interaction using the built-in presentation components. Message sources already share the built-in body renderer and source presentation.
|
|
101
105
|
|
|
102
106
|
The plugin supplies business state for the associated Agent and callbacks for user actions. A component becoming invisible does not complete or cancel waiting backend work. Remounting should reread current state, and each submission entry owns its pending and error state.
|
|
@@ -6,4 +6,6 @@ Declare creation once and pass that original contract to the integration. A stra
|
|
|
6
6
|
|
|
7
7
|
Creation participates in the host's resource and history operations. The created object links to the invoking agent. Optional initial resources remain within the request's captured resource scope. Explicit self-exposure supplies the reverse relationship; a new resource does not inherit every link or capability of its creator.
|
|
8
8
|
|
|
9
|
+
Initial self-exposure is optional. After creation, the agent can use `resource_expose` to enable or withdraw its exposure to a resource in its captured request scope. The recipient must support receiving links; the agent's access to that recipient remains independent.
|
|
10
|
+
|
|
9
11
|
Use descriptions and schemas that explain what the resulting resource means and what inputs the model should supply. Creating another agent is also an explicit domain operation with its own configuration and initial links.
|
package/package.json
CHANGED
package/src/agent.ts
CHANGED
|
@@ -14,7 +14,9 @@ export const agentInputModeSchema = z.enum(["steer", "follow"]);
|
|
|
14
14
|
/** Submissions and drafts share a 16-character Nano ID identity. */
|
|
15
15
|
export const submissionIdSchema = z.string().regex(/^[A-Za-z0-9_-]{16}$/u);
|
|
16
16
|
export const StartAgentSession = defineCall(builtin.name("session.start"), {
|
|
17
|
-
scope: "plugin", input: z.strictObject({ submissionId: submissionIdSchema, selection: agentSelectionSchema, parts: agentInputPartsSchema
|
|
17
|
+
scope: "plugin", input: z.strictObject({ submissionId: submissionIdSchema, selection: agentSelectionSchema, parts: agentInputPartsSchema,
|
|
18
|
+
/** Host folder for the new session; null leaves it without a folder. */
|
|
19
|
+
folderId: z.string().uuid().nullable() }),
|
|
18
20
|
output: z.strictObject({ sessionId: z.string().min(1) }),
|
|
19
21
|
});
|
|
20
22
|
/** title is optional; when omitted, the creation entry point generates a random display name. */
|
package/src/records.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { defineRecord, modelBlockSchema, modelCompletionSchema
|
|
2
|
+
import { defineRecord, defineOperationRecord, modelBlockSchema, modelToolCallBlockSchema, modelCompletionSchema, toolOutcomeSchema,
|
|
3
|
+
type Decoded, type SessionRecord, type ModelBlock } from "@asterism-app/sdk/contracts";
|
|
3
4
|
import { builtin } from "./identity.ts";
|
|
4
5
|
import { agentMessageSenderSchema } from "./messaging.ts";
|
|
5
6
|
import { agentInputPartSchema } from "./input.ts";
|
|
@@ -11,6 +12,24 @@ export const AgentInputMessage = defineRecord(builtin.name("agent.input-message"
|
|
|
11
12
|
export const Execution = defineRecord(builtin.name("agent.execution"), {
|
|
12
13
|
schema: z.strictObject({ type: z.literal("block"), block: modelBlockSchema }),
|
|
13
14
|
});
|
|
15
|
+
/** Tool inputs keep their model-order position; execution fills the outcome once. */
|
|
16
|
+
export const ToolExecution = defineOperationRecord(builtin.name("agent.tool-execution"), {
|
|
17
|
+
input: modelToolCallBlockSchema.refine(block => !block.complete && block.outcome === null && block.argumentsText === null,
|
|
18
|
+
"Tool operation input must have complete arguments and a pending outcome."),
|
|
19
|
+
output: toolOutcomeSchema,
|
|
20
|
+
});
|
|
21
|
+
export const executionRecordIds = [Execution.id, ToolExecution.id];
|
|
22
|
+
/** Read both immutable blocks and tool operations through the same historical block projection.
|
|
23
|
+
* submitted marks a tool call handed to execution; without an outcome its effects are unknown rather than absent. */
|
|
24
|
+
export function decodeExecution(record: SessionRecord): Decoded<{ type: "block"; block: ModelBlock; submitted?: true }> | null {
|
|
25
|
+
const operation = ToolExecution.decode(record);
|
|
26
|
+
if (!operation) return Execution.decode(record);
|
|
27
|
+
if (operation.status === "unknown") return operation;
|
|
28
|
+
const { input, output } = operation.data;
|
|
29
|
+
return { status: "known", record, data: { type: "block", submitted: true, block: {
|
|
30
|
+
...input, complete: output !== null, outcome: output,
|
|
31
|
+
} } };
|
|
32
|
+
}
|
|
14
33
|
/** A summary replaces only the prefix of model input; keptFrom points to the first history node retained unchanged. */
|
|
15
34
|
export const ContextSummary = defineRecord(builtin.name("agent.context-summary"), {
|
|
16
35
|
schema: z.strictObject({
|
package/src/tools.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
|
-
import { defineTool } from "@asterism-app/sdk/contracts";
|
|
2
|
+
import { defineTool, fileRefSchema } from "@asterism-app/sdk/contracts";
|
|
3
3
|
import { builtin } from "./identity.ts";
|
|
4
4
|
import { editOperationSchema } from "./text.ts";
|
|
5
5
|
|
|
@@ -64,6 +64,12 @@ export const Write = defineTool({
|
|
|
64
64
|
content: z.string().describe("The complete new UTF-8 text. Empty content clears the target."),
|
|
65
65
|
}).describe("Full replacement text. The implementation specifies its content size limit."),
|
|
66
66
|
});
|
|
67
|
+
export const Save = defineTool({
|
|
68
|
+
id: builtin.name("tool.save"), name: "save",
|
|
69
|
+
description: "Save the bytes of a referenced file to a target.",
|
|
70
|
+
guidelines: ["The resource implementation defines destination paths and replacement behavior."],
|
|
71
|
+
argsSchema: z.strictObject({ ref: fileRefSchema }).describe("The source file reference. The target selects the destination."),
|
|
72
|
+
});
|
|
67
73
|
|
|
68
74
|
export const Replace = defineTool({
|
|
69
75
|
id: builtin.name("tool.replace"),
|