@asterism-app/builtin-api 0.22.0 → 0.24.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/messaging.ts +2 -2
- package/src/records.ts +20 -1
- package/src/search.ts +7 -11
- package/src/text.ts +7 -2
- package/src/tools.ts +9 -6
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/messaging.ts
CHANGED
|
@@ -29,8 +29,8 @@ export const Send = defineTool({
|
|
|
29
29
|
id: builtin.name("tool.send"), name: "send",
|
|
30
30
|
description: "Send text and file references through a linked resource.",
|
|
31
31
|
guidelines: [
|
|
32
|
-
"resource_id selects the messaging resource. Its target schema
|
|
33
|
-
"The
|
|
32
|
+
"resource_id selects the messaging resource. Its target schema defines the destination and any reply options.",
|
|
33
|
+
"The resource implementation determines the sending identity and delivery behavior.",
|
|
34
34
|
"A file-reference part carries a FileRef in its ref field. The optional filename specifies the name used for delivery.",
|
|
35
35
|
"Referenced content is resolved by the consuming implementation.",
|
|
36
36
|
],
|
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/search.ts
CHANGED
|
@@ -4,9 +4,7 @@ import { builtin } from "./identity.ts";
|
|
|
4
4
|
|
|
5
5
|
const pattern = z.string().min(1).refine(value => !value.includes("\0"), "Patterns must be free of NUL characters.");
|
|
6
6
|
const selection = {
|
|
7
|
-
|
|
8
|
-
noIgnore: z.boolean().optional().describe("Disable ignore-file filtering; defaults to false. Hidden-entry filtering is controlled separately by hidden."),
|
|
9
|
-
limit: z.number().int().positive().max(2000).optional().describe("Maximum returned matching lines in grep content mode, or files otherwise; defaults to 500, maximum 2000. Context lines are bounded only by the output-byte budget. Matching lines with omitted content count toward the limit."),
|
|
7
|
+
limit: z.number().int().positive().max(2000).optional().describe("Maximum returned matching lines, or entries in another resource-specific view; defaults to 500, maximum 2000. Context lines are bounded only by the output-byte budget."),
|
|
10
8
|
};
|
|
11
9
|
const globGuidelines = [
|
|
12
10
|
"Globs use ripgrep semantics. A pattern without '/' such as '*.md' matches filenames at any depth.",
|
|
@@ -19,30 +17,28 @@ export const Find = defineTool({
|
|
|
19
17
|
guidelines: globGuidelines,
|
|
20
18
|
argsSchema: z.strictObject({
|
|
21
19
|
pattern: pattern.describe("File glob relative to the selected search directory, using '/' separators; for example '**/*.ts' or '**/package.json'."),
|
|
20
|
+
hidden: z.boolean().optional().describe("Disable hidden-entry filtering; defaults to false. Ignore-file filtering is controlled separately by noIgnore."),
|
|
21
|
+
noIgnore: z.boolean().optional().describe("Disable ignore-file filtering; defaults to false. Hidden-entry filtering is controlled separately by hidden."),
|
|
22
22
|
...selection,
|
|
23
23
|
}).describe("A file glob and search selection options."),
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
export const Grep = defineTool({
|
|
27
27
|
id: builtin.name("tool.grep"), name: "grep",
|
|
28
|
-
description: "Search
|
|
28
|
+
description: "Search text for a regular expression or literal pattern within a resource.",
|
|
29
29
|
guidelines: [
|
|
30
|
-
"
|
|
30
|
+
"Results identify matching lines and surrounding context. Resource implementations define additional output views.",
|
|
31
31
|
"Regular expressions use ripgrep's default Rust regex syntax. Matching is line-oriented.",
|
|
32
|
-
"
|
|
33
|
-
...globGuidelines,
|
|
32
|
+
"target selects the search scope and resource-specific content view according to the resource implementation's schema.",
|
|
34
33
|
],
|
|
35
34
|
argsSchema: z.strictObject({
|
|
36
35
|
pattern: pattern.describe("Pattern in ripgrep's default Rust regex syntax, without / delimiters. Matching is line-oriented; lookaround and pattern backreferences are unsupported. When literal is true, this is literal text."),
|
|
37
36
|
literal: z.boolean().optional().describe("Interpret pattern as literal text; defaults to false."),
|
|
38
37
|
ignoreCase: z.boolean().optional().describe("Use case-insensitive matching; defaults to false."),
|
|
39
38
|
word: z.boolean().optional().describe("Match only at word boundaries; defaults to false."),
|
|
40
|
-
glob: z.array(pattern).optional().describe("File globs relative to the search directory. Prefix exclusions with '!'; later globs take precedence."),
|
|
41
39
|
context: z.number().int().min(0).max(20).optional().describe("Lines before and after each match in content mode; defaults to 0."),
|
|
42
|
-
outputMode: z.enum(["content", "files", "count"]).optional().describe("Result format; defaults to content. Count means matching lines, rather than regex occurrences."),
|
|
43
|
-
anchored: z.boolean().optional().describe("Include edit anchors in content mode; defaults to true."),
|
|
44
40
|
...selection,
|
|
45
|
-
}).describe("
|
|
41
|
+
}).describe("Text pattern, matching options, context and result limit."),
|
|
46
42
|
});
|
|
47
43
|
|
|
48
44
|
export type FindArgs = z.infer<typeof Find.argsSchema>;
|
package/src/text.ts
CHANGED
|
@@ -20,20 +20,25 @@ export const editOperationSchema = z.discriminatedUnion("op", [
|
|
|
20
20
|
export const textRowSchema = z.strictObject({
|
|
21
21
|
line: z.number().int().positive().describe("The absolute 1-based line number in the complete text."),
|
|
22
22
|
content: z.string().describe("The line content without its terminator; for an excerpt, only the excerpt window."),
|
|
23
|
-
hash: z.string().nullable().describe("LINE#HASH content hash of the complete line, also for an excerpt; null when
|
|
23
|
+
hash: z.string().nullable().describe("LINE#HASH content hash of the complete line, also for an excerpt; null when the selected view has no edit anchors."),
|
|
24
24
|
excerpt: z.strictObject({
|
|
25
25
|
start: z.number().int().nonnegative().describe("UTF-16 offset of content within the complete line."),
|
|
26
26
|
length: z.number().int().positive().describe("UTF-16 length of the complete line."),
|
|
27
27
|
}).nullable().describe("Present when the line is too long to return in full; content is then a window of the complete line. Null for a complete line."),
|
|
28
28
|
});
|
|
29
29
|
export type TextRow = z.infer<typeof textRowSchema>;
|
|
30
|
+
export const textReadTargetSchema = z.strictObject({
|
|
31
|
+
offset: z.number().int().positive().optional().describe("First line to read, 1-based in the complete text; defaults to 1."),
|
|
32
|
+
limit: z.number().int().positive().max(2000).optional().describe("Maximum lines to read; defaults to 1000, maximum 2000. Output is also limited to 64 KiB of line text; lines longer than 16000 characters are returned as excerpts."),
|
|
33
|
+
anchored: z.boolean().optional().describe("Include LINE#HASH edit anchors; defaults to true. Anchors identify complete lines, including those displayed as excerpts. False returns text with line numbers only."),
|
|
34
|
+
});
|
|
30
35
|
export const textReadSchema = z.strictObject({
|
|
31
36
|
totalLines: z.number().int().nonnegative().describe("Number of logical lines in the complete text; empty text has zero lines."),
|
|
32
37
|
fromLine: z.number().int().positive().describe("First requested line, counted from 1 in the complete text."),
|
|
33
38
|
rows: z.array(textRowSchema).describe("Selected lines and their available edit anchors; long lines are returned as excerpts."),
|
|
34
39
|
noFinalNewline: z.boolean().describe("Whether non-empty text lacks a final newline."),
|
|
35
40
|
nextOffset: z.number().int().positive().nullable().describe("First unread line after the returned range, or null at end of text. Use as target.offset only when this implementation supports line selection."),
|
|
36
|
-
}).describe("Selected text lines
|
|
41
|
+
}).describe("Selected text lines with available edit anchors, final-newline information and a continuation position.");
|
|
37
42
|
|
|
38
43
|
export const textChangeSchema = z.strictObject({
|
|
39
44
|
changed: z.boolean().describe("Whether the target was created or its content changed."),
|
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
|
|
|
@@ -23,13 +23,10 @@ export const Read = defineTool({
|
|
|
23
23
|
name: "read",
|
|
24
24
|
description: "Read the selected content as text.",
|
|
25
25
|
guidelines: [
|
|
26
|
-
"target selects the content and
|
|
27
|
-
"Editable text includes LINE#HASH edit anchors by default; args:{\"anchored\":false} omits them. Content that cannot be edited has no anchors.",
|
|
26
|
+
"target selects the content, range, and reading view according to the resource implementation's schema.",
|
|
28
27
|
"The result reports positions and a continuation point where the implementation supports ranges.",
|
|
29
28
|
],
|
|
30
|
-
argsSchema: z.strictObject({
|
|
31
|
-
anchored: z.boolean().optional().describe("Include edit anchors for editable text; defaults to true."),
|
|
32
|
-
}).describe("Reading behavior. Content selection and range belong to target."),
|
|
29
|
+
argsSchema: z.strictObject({}).describe("Empty parameter object. Content selection, range, and reading view belong to target."),
|
|
33
30
|
});
|
|
34
31
|
|
|
35
32
|
export const Edit = defineTool({
|
|
@@ -64,6 +61,12 @@ export const Write = defineTool({
|
|
|
64
61
|
content: z.string().describe("The complete new UTF-8 text. Empty content clears the target."),
|
|
65
62
|
}).describe("Full replacement text. The implementation specifies its content size limit."),
|
|
66
63
|
});
|
|
64
|
+
export const Save = defineTool({
|
|
65
|
+
id: builtin.name("tool.save"), name: "save",
|
|
66
|
+
description: "Save the bytes of a referenced file to a target.",
|
|
67
|
+
guidelines: ["The resource implementation defines destination paths and replacement behavior."],
|
|
68
|
+
argsSchema: z.strictObject({ ref: fileRefSchema }).describe("The source file reference. The target selects the destination."),
|
|
69
|
+
});
|
|
67
70
|
|
|
68
71
|
export const Replace = defineTool({
|
|
69
72
|
id: builtin.name("tool.replace"),
|