@asterism-app/sdk 1.4.1 → 1.5.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/resources-and-tools.md +6 -2
- package/package.json +1 -1
- package/src/model-provider.ts +1 -1
- package/src/module-contract.ts +1 -0
- package/src/provider-settings.ts +1 -1
- package/src/renderer-services.ts +3 -1
- package/src/renderer-tools.ts +8 -3
- package/src/runtime-contracts.ts +1 -0
- package/src/runtime-tools.ts +1 -0
|
@@ -24,9 +24,9 @@ Use a session snapshot to query the resources directly linked to a receiver. Res
|
|
|
24
24
|
|
|
25
25
|
Use a resource tool when an operation targets a linked object. A shared tool can have implementations for different resource types, each with an appropriate internal target and result.
|
|
26
26
|
|
|
27
|
-
Choose a tool name for the operation's meaning. Reuse an existing tool declaration when its semantics and operation arguments fit another resource; supply that resource's target and result schemas in its implementation. A distinct operation contract needs a distinct name. Domain qualifiers can clarify scope, such as `terminal_input` for terminal interaction, and remain useful when multiple resource types support that operation. Choose qualifiers according to the operation's meaning, independently of whether its declaration is public or where its code lives.
|
|
27
|
+
Choose a tool name for the operation's meaning. Reuse an existing tool declaration when its semantics and operation arguments fit another resource; supply that resource's target and result schemas in its implementation. The result schema decodes and encodes that implementation's output. A distinct operation contract needs a distinct name. Domain qualifiers can clarify scope, such as `terminal_input` for terminal interaction, and remain useful when multiple resource types support that operation. Choose qualifiers according to the operation's meaning, independently of whether its declaration is public or where its code lives.
|
|
28
28
|
|
|
29
|
-
For model calls, `resource_id` selects the resource, `args` supplies the operation's shared parameters, and `target` selects content, scope, or a resource-specific view. A reading target can select a file, a line range, and whether its text includes edit anchors. Each implementation declares the selections it supports. The same tool preserves its meaning and `args` schema across resources. Inspection exposes the tools available on the selected resource
|
|
29
|
+
For model calls, `resource_id` selects the resource, `args` supplies the operation's shared parameters, and `target` selects content, scope, or a resource-specific view. A reading target can select a file, a line range, and whether its text includes edit anchors. Each implementation declares the selections it supports. The same tool preserves its meaning and `args` schema across resources. Inspection exposes the tools available on the selected resource with their argument and target schemas. A result schema defines how output is encoded for storage and transport, so it is not published to models; an actual outcome shows what an operation returns.
|
|
30
30
|
|
|
31
31
|
Use a top-level tool for operations on the execution context or shared resource lifecycle, such as creation and renaming. The host supplies caller identity and execution scope.
|
|
32
32
|
|
|
@@ -34,10 +34,14 @@ Both resource tools and top-level tools receive `caller`, containing the access
|
|
|
34
34
|
|
|
35
35
|
Describe the operation's purpose and observable behavior. Parameters should explain business meaning that names and types alone do not express. Results should distinguish known success, failure, cancellation, partial output, and uncertain effects.
|
|
36
36
|
|
|
37
|
+
Declare `execution: "sequential"` when an operation must preserve submission order relative to other sequential operations in the request. Parallel operations can overlap either category. This execution policy is independent of the operation's read/write effect. Direct model calls and resource script calls share validation, scheduling, and completion, so tools require no separate script implementation.
|
|
38
|
+
|
|
37
39
|
A tool contribution can capture resource-specific configuration and access at the start of each model request. Return a bound contribution using the same implementation contract; the host uses it for that request's tool batch. This is useful for a resource whose selected network or reachable objects can change while a model is responding. Capture addressing and authorization facts, while reading ordinary mutable content when the operation runs.
|
|
38
40
|
|
|
39
41
|
Declare `requiresInteraction: true` when a tool cannot complete without user interaction. The host excludes it from noninteractive requests and rejects unsupported calls before entering the implementation. Tools supporting both modes can inspect `interactive` in their execution context. A renderer that only displays progress or results does not make a tool interactive.
|
|
40
42
|
|
|
43
|
+
Resource inspection includes the interaction requirement. Resource scripts are noninteractive surfaces, including within an interactive model request; interaction-required operations use direct model calls. Their other execution and authorization contracts remain shared.
|
|
44
|
+
|
|
41
45
|
Use `plugin.execution.run` to execute one model request with tools bound to a resource's current links and the real session. Supply that resource as the access owner and select the interaction capability. The execution holds captured relationships through the tool batch; subsequent calls capture current links again. Calls sharing an access owner keep independent message inputs and can run concurrently.
|
|
42
46
|
|
|
43
47
|
Supply the executing role's name through `agent` and any resource type allowlist or denylist through `resources`. The host captures these inputs with the request. Resource policy is enforced by the shared dispatcher: inspection retains resource state and tool schemas with a notice naming a denied role, and calls on restricted types are rejected before the implementation runs. Listing and linked context remain available. Individual resource tools need no role-policy checks.
|
package/package.json
CHANGED
package/src/model-provider.ts
CHANGED
|
@@ -24,7 +24,7 @@ export interface ModelProviderPreset {
|
|
|
24
24
|
verifiedOn: string;
|
|
25
25
|
keywords?: readonly string[];
|
|
26
26
|
}
|
|
27
|
-
const webUrl = z.
|
|
27
|
+
const webUrl = z.url({ protocol: /^https?$/ });
|
|
28
28
|
export const modelProviderConnectionSchema = z.strictObject({
|
|
29
29
|
protocol: z.enum(["openai-responses", "openai-chat", "anthropic"]),
|
|
30
30
|
baseUrl: webUrl, auth: z.enum(["api_key", "none"]),
|
package/src/module-contract.ts
CHANGED
|
@@ -21,6 +21,7 @@ export interface ImplementationContract<S extends Json, T extends Json, A extend
|
|
|
21
21
|
tool: ToolContract<A>;
|
|
22
22
|
targetSchema: z.ZodType<T>;
|
|
23
23
|
effect: "read" | "write";
|
|
24
|
+
/** Sequential operations share submission order; parallel operations can overlap either lane. */
|
|
24
25
|
execution: "parallel" | "sequential";
|
|
25
26
|
}
|
|
26
27
|
export function defineResource<S extends Json>(kind: string, stateSchema: z.ZodType<S>): ResourceContract<S> {
|
package/src/provider-settings.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { z } from "zod";
|
|
2
2
|
import { uiTextSchema } from "./i18n.ts";
|
|
3
3
|
|
|
4
|
-
const helpUrlSchema = z.
|
|
4
|
+
const helpUrlSchema = z.url({ protocol: /^https?$/, error: "An HTTP or HTTPS URL is required." });
|
|
5
5
|
const base = { key: z.string().regex(/^[A-Za-z][A-Za-z0-9_]*$/u), label: uiTextSchema, description: uiTextSchema.optional() };
|
|
6
6
|
|
|
7
7
|
/**
|
package/src/renderer-services.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { createContext, useContext } from "react";
|
|
1
|
+
import { createContext, useContext, type ReactNode } from "react";
|
|
2
2
|
import type { Json } from "./json.ts";
|
|
3
3
|
import type { DataContract } from "./presentation.ts";
|
|
4
4
|
import type { ConfigContract } from "./config.ts";
|
|
@@ -19,6 +19,8 @@ export interface RendererTools {
|
|
|
19
19
|
preparation(name: string): string;
|
|
20
20
|
/** Localized name of a tool by its model-facing name and implementation contract; null when no view declares one. */
|
|
21
21
|
label(name: string, implementation: string | null): string | null;
|
|
22
|
+
/** Static icon of a tool by the same identity; null when no view declares one. */
|
|
23
|
+
icon(name: string, implementation: string | null): ReactNode;
|
|
22
24
|
}
|
|
23
25
|
export interface RendererModels { readonly blocks: readonly ModelLiveBlock[] }
|
|
24
26
|
export interface RendererNavigation { home(): void }
|
package/src/renderer-tools.ts
CHANGED
|
@@ -48,6 +48,8 @@ export interface ToolExecutionPhaseView<P> extends ToolStreamingPhaseView<P> {
|
|
|
48
48
|
export interface ToolRendererDefinition<D = Json, T = Json, A = Json> {
|
|
49
49
|
label?: UiText;
|
|
50
50
|
icon?: ReactNode;
|
|
51
|
+
/** Whether the conversation shell exposes raw argument/result details; defaults to true. */
|
|
52
|
+
details?: boolean;
|
|
51
53
|
input?: ToolStreamingPhaseView<ToolInputRenderProps>;
|
|
52
54
|
execution?: ToolExecutionPhaseView<ToolExecutionRenderProps<D, T, A>>;
|
|
53
55
|
result?: ToolPhaseView<ToolResultRenderProps<D, T, A>>;
|
|
@@ -55,6 +57,7 @@ export interface ToolRendererDefinition<D = Json, T = Json, A = Json> {
|
|
|
55
57
|
export interface ToolView {
|
|
56
58
|
label?: UiText;
|
|
57
59
|
icon?: ReactNode;
|
|
60
|
+
details?: boolean;
|
|
58
61
|
header?: ReactNode;
|
|
59
62
|
body?: ReactNode;
|
|
60
63
|
/** Bodies in input or execution phases may participate in streaming preview expansion and collapse; false means no match this time, and phase completion is determined by the call lifecycle. */
|
|
@@ -66,14 +69,16 @@ export interface ToolRenderer {
|
|
|
66
69
|
contract: ContractReference;
|
|
67
70
|
/** Display name of the tool, readable without rendering a call. */
|
|
68
71
|
label?: UiText;
|
|
72
|
+
/** Static operation icon, available to call summaries without rendering arguments or results. */
|
|
73
|
+
icon?: ReactNode;
|
|
69
74
|
resolve(props: ToolRenderProps): ToolView | null;
|
|
70
75
|
}
|
|
71
76
|
|
|
72
77
|
function render<P extends { phase: ToolRenderProps["phase"] }>(
|
|
73
|
-
definition: Pick<ToolView, "label" | "icon">, view: ToolExecutionPhaseView<P> | undefined, props: P,
|
|
78
|
+
definition: Pick<ToolView, "label" | "icon" | "details">, view: ToolExecutionPhaseView<P> | undefined, props: P,
|
|
74
79
|
): ToolView {
|
|
75
80
|
return {
|
|
76
|
-
label: definition.label, icon: definition.icon,
|
|
81
|
+
label: definition.label, icon: definition.icon, details: definition.details,
|
|
77
82
|
header: view?.headerRenderer ? createElement(view.headerRenderer, props) : undefined,
|
|
78
83
|
body: view?.bodyRenderer ? createElement(view.bodyRenderer, props) : undefined,
|
|
79
84
|
streaming: (props.phase === "input" || props.phase === "executing")
|
|
@@ -87,7 +92,7 @@ export function toolRenderer<D extends Json, T extends Json = Json, A extends Js
|
|
|
87
92
|
contract: DataContract<D> & { targetSchema?: z.ZodType<T>; tool?: { argsSchema: z.ZodType<A> } },
|
|
88
93
|
definition: ToolRendererDefinition<D, T, A>,
|
|
89
94
|
): ToolRenderer {
|
|
90
|
-
return { contract: reference(contract), label: definition.label, resolve(props) {
|
|
95
|
+
return { contract: reference(contract), label: definition.label, icon: definition.icon, resolve(props) {
|
|
91
96
|
if (props.phase === "input") return definition.input ? render(definition, definition.input, props) : null;
|
|
92
97
|
const data = props.result?.data;
|
|
93
98
|
const parsed = data === null || data === undefined ? null : contract.schema.safeParse(data);
|
package/src/runtime-contracts.ts
CHANGED
|
@@ -155,6 +155,7 @@ export type PreparedResult = CallResult & ToolInvocationInfo;
|
|
|
155
155
|
export type ToolCaller = Readonly<Pick<ResourceSnapshot, "ref" | "title"> & { agent?: string }>;
|
|
156
156
|
export interface ToolInvocation extends ToolInvocationInfo {
|
|
157
157
|
effect: "read" | "write";
|
|
158
|
+
/** Sequential operations share submission order; parallel operations can overlap either lane. */
|
|
158
159
|
execution: "parallel" | "sequential";
|
|
159
160
|
execute(signal: AbortSignal, publish?: (data: Json) => void): Promise<CallResult>;
|
|
160
161
|
toModel?(data: Json): ToolModelOutput;
|
package/src/runtime-tools.ts
CHANGED
|
@@ -19,6 +19,7 @@ export interface TopLevelTool<A extends Json = Json, D extends Json = Json> exte
|
|
|
19
19
|
/** Encodes D for progress/history and decodes it for views and model projection. */
|
|
20
20
|
readonly resultSchema: z.ZodType<D>;
|
|
21
21
|
readonly effect: "read" | "write";
|
|
22
|
+
/** Sequential operations share submission order; parallel operations can overlap either lane. */
|
|
22
23
|
readonly execution: "parallel" | "sequential";
|
|
23
24
|
execute(args: A, context: TopLevelToolContext<D>): Promise<CallResult<D>>;
|
|
24
25
|
toModel?(data: D): ToolModelOutput;
|