@asterism-app/sdk 1.10.1 → 1.11.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.
@@ -1,73 +1,53 @@
1
- # Add resources and tools
1
+ # Design resources and callable capabilities
2
2
 
3
- A resource represents an object with identity and lifetime. A tool represents a model-callable operation. They can evolve independently.
3
+ A resource represents an object with identity and lifetime. A tool represents a model-callable operation. Keeping them independent lets the same operation work across different objects without forcing those objects into one domain model.
4
4
 
5
- ## Add an object
5
+ ## Choose the object boundary
6
6
 
7
- Use a resource for something that belongs in a session and can be inspected or operated on. Define how it is created, what state it owns, and what information it presents.
7
+ Use a resource for something that belongs in a session and can be recognized or operated on independently. Give it responsibility for its state, model-facing projection, and object-owned work.
8
8
 
9
- The resource attaches when it becomes present in a session. Removal immediately ends discovery and cancels its managed tasks and model requests. Other owners' requests holding the resource can finish before its attachment lifetime ends and the instance is disposed. A hidden card does not imply that its backend instance should stop.
9
+ A card is a presentation of that object, not its backend lifetime. Hiding a card should not silently end work that remains meaningful without it. Conversely, retaining saved data is not a reason to keep a live process running.
10
10
 
11
- Creation supplies initial state. Actions change the object through typed application or plugin operations. Views present the resulting state.
11
+ Ask for disposal confirmation when ending a live instance has consequences the user should decide about. Base the warning on work that actually exists, not on saved state that could hypothetically be restored. Warning discovery and cleanup have different purposes.
12
12
 
13
- Implement `inspect` to expose model-facing resource state. The host includes this state in resource listings and individual inspection results; individual inspection also supplies available tool definitions. Link notifications contain identity only. Return the information needed to recognize and use the resource without relying on the host to interpret its saved state.
13
+ ## Design information and access separately
14
14
 
15
- Resource titles belong to session history. Use the session's rename operation with a resource reference to change a title; the host appends the event and reconstructs names along each history path. Tool sessions accept a resource ID within the request's captured links. Existing snapshots keep their captured titles.
15
+ A resource's model-facing state should let a model recognize the object and understand its relevant condition. Keep that projection with the resource implementation rather than relying on the host to interpret private saved state. Tool definitions explain operations; they are not a substitute for object state.
16
16
 
17
- Declare `links: { receive: true }` in the backend resource implementation when the object can receive directed links. The host supplies this capability to the workbench's connection controls and authorization panel. Renderer resource descriptions supply labels, icons, and card geometry; link reception needs no frontend declaration.
17
+ Directed links express availability to a receiver. The reverse relationship is independent, and a path through another object is not implicit access. A readable title, reference, or member directory does not grant authority over the object it names.
18
18
 
19
- Within a tool, `session.link(receiverId)` exposes the bound caller to a recipient in the request's captured resource scope, and `session.unlink(receiverId)` withdraws that exposure. The host supplies the caller identity. These operations preserve the recipient's link to the caller and cannot authorize additional resources for the caller. Subsequent requests capture the updated relationships; active requests retain their captured access.
19
+ For example, a bridge can choose recipients from its direct links without acquiring their private business state. Read current relationships when handling a new external event; a model request already in progress uses its captured scope.
20
20
 
21
- Use a session snapshot to query the resources directly linked to a receiver. Results contain resource references, titles, and public data on that snapshot's timeline path. Reverse links and links through another resource are independent. For external event handling, such as forwarding network messages to linked agents, read a fresh snapshot for each event. Session observers can also query their supplied snapshot after commits or cursor changes. The query exposes relationships without granting access to private state or expanding a model request's operation scope.
21
+ ## Choose a callable boundary
22
22
 
23
- ## Add a model operation
23
+ An application action or service call need not be a model tool. Expose it when a model needs that capability, and keep the implementation's business logic shared with other callers where appropriate.
24
24
 
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.
25
+ Reuse a tool declaration when the operation has the same meaning and shared arguments across resources. Keep resource-specific selection with the implementation. A distinct meaning deserves a distinct contract even when its code happens to resemble another operation.
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. 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.
27
+ A read operation illustrates the distinction: reading keeps its meaning while a resource decides how content is addressed and which view is useful. Name operations by that meaning, not by the file or package that happens to declare them.
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 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.
29
+ Use a top-level capability for operations on the execution context or shared resource lifecycle, rather than inventing a placeholder resource solely to host them.
30
30
 
31
- Tool arguments and resource targets are JSON objects or null. Declare a named field for a scalar or collection, such as `{ title: string }` or `{ ids: string[] }`. Object members may contain any JSON value; each tool determines its fields and whether it accepts null. Resource calls default an omitted target to null and omitted arguments to `{}`. Direct calls and resource scripts use the same input shapes.
31
+ ## Put invocation knowledge in the contract
32
32
 
33
- 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.
33
+ Tool descriptions, guidelines, and schemas must support use independently of the manual. Explain purpose, how outputs relate to later inputs, input meaning, result interpretation, and execution boundaries in the owning contract.
34
34
 
35
- Both resource tools and top-level tools receive `caller`, containing the access owner's resource reference and title. When the executing paradigm supplies an Agent role name, it is available as `caller.agent`. The role identifies the executing configuration independently of the access owner; several roles can execute through one shared resource. Role identity carries no configuration object or additional resource access.
35
+ Use examples to clarify data flow without prescribing a workflow. Describe an operation's own use of a file reference rather than assuming which resource produced it or which consumer follows it. Distinguish failure, cancellation, partial output, and uncertain effects when those differences affect what a caller can conclude.
36
36
 
37
- 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.
37
+ Choose scheduling according to ordering requirements, not simply whether an operation reads or writes. Require interaction only when completion depends on a user response; showing progress alone does not make backend work interactive.
38
38
 
39
- 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.
39
+ ## Compose model execution deliberately
40
40
 
41
- 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.
41
+ Session-bound model execution is useful when a request should act through a resource's links and real session. Direct model execution suits work whose messages and executable tools are supplied by the caller without a workbench object. Choose based on the access and history relationship, not on a presumed requirement to create an Agent.
42
42
 
43
- 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.
43
+ Capture configuration and authorization at the request boundary. Read ordinary mutable content when handling an operation. For a resource addressing a selected network, this keeps the meaning of its addresses stable through the tool batch without pretending the network's content is frozen.
44
44
 
45
- 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.
45
+ The caller owns conversation policy, historical recording, and retry decisions. Keep transient progress distinct from durable operation results. A generation failure does not necessarily mean that every earlier tool effect failed or that repeating the request is safe.
46
46
 
47
- 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.
47
+ Resource access and timeline activity are also separate. Work that depends on a history position needs the appropriate activity scope; merely holding access to a resource does not establish that dependency. Temporary conversations need explicit ownership of attachments that must survive into later requests.
48
48
 
49
- 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. Resource listings retain state, inspection retains state and tool schemas, and both include a tool-call restriction notice naming the role when supplied. Calls on restricted types are rejected before the implementation runs. Creation and linked context remain available. Top-level tools can query the captured tool-call restriction by resource type to annotate discovery results, including creation catalogs, without re-reading role configuration. Individual resource tools need no role-policy checks.
49
+ ## Separate services from their interfaces
50
50
 
51
- Resource holds do not block history movement. Use an object busy scope for work that depends on the timeline, such as a conversation writing its responses there. Object-bound managed tasks protect history by default; use `affectsHistory: false` for external runtime tasks that should still stop when their owning resource leaves the session.
51
+ A backend capability does not automatically need a resource card or a model tool. Typed calls, events, and sustained channels serve different interaction needs; choose them according to whether the consumer requests a result, observes a change, or maintains a live connection.
52
52
 
53
- Use `plugin.models.run` when supplying messages and executable tools directly. It needs no workbench resource or timeline. Both forms deliver execution records to the observer you provide. `plugin.execution.withProgress` supplies an optional workbench observer for the events you choose to display.
54
-
55
- Tool input events arrive in model order before the batch executes. A consumer can begin an operation record for each input, then fill that record when its tool completion event arrives. Progress remains transient. Response termination metadata describes model generation independently of tool outcomes, including available diagnostics after a failed stream. The caller owns retry policy and can use the returned failure's retryability without interpreting provider error strings.
56
-
57
- For a temporary conversation, use a content scope to retain generated attachments across requests. Pass it as the input reader and output owner for session-bound execution. Persistent records or a longer-lived scope must retain any surviving results before the temporary scope closes.
58
-
59
- ## Connect other interactions
60
-
61
- Typed calls connect request and response between services or views. Events announce transient changes. Object channels support sustained data such as an interactive screen.
62
-
63
- An action or service call is not automatically a model tool. Expose it deliberately when the model needs that operation.
64
-
65
- ## Use shell capabilities
66
-
67
- Backend plugins access shell profiles, one-shot execution, and interactive terminals through `plugin.shell`. Profiles are shared host configuration: `profiles.get()` reads that configuration, while `profiles.list()` resolves executable availability. Plugins choose how to expose these capabilities through their resources and tools.
68
-
69
- Use `shell.execute(cwd, args, options)` for a noninteractive command with piped output, progress, and a final result. Each execution owns its process; cancellation or timeout stops that execution without undoing completed effects.
70
-
71
- Use `shell.terminals.create(config, events)` for a persistent interactive session. Start the returned handle when needed and register its disposal with the owning resource or plugin lifetime. Closing a terminal permits reopening the handle; disposing it releases it permanently. Input and readiness waits are separate operations, and cancelling a wait leaves the shell running.
72
-
73
- A terminal can serve several views through its typed input/output messages. Plugins connect viewers through object channels and choose their own presentation. Backend reads expose screen text, retained output, or character-cell image data. The host owns the PTY and screen state; a terminal handle does not create a workbench resource or model tool by itself.
53
+ For example, a one-shot shell process and a persistent terminal need different owners. Cancelling a command concerns that process; closing one terminal view need not end a shell shared with other views. Host services supply the execution mechanics, while the plugin chooses the domain object, presentation, and callable interface.
@@ -1,31 +1,29 @@
1
- # Provide a session entry
1
+ # Design a session starting point
2
2
 
3
- A session contains a history tree and a workbench. A plugin can start work with any supported resources, or with an empty workbench. An initial message and an Agent resource are optional domain choices.
3
+ A session contains a history tree and a workbench. Its starting point can be an empty workspace or a set of resources prepared for a task. An Agent and an initial message are domain choices, not prerequisites for starting work.
4
4
 
5
- ## Own the starting interface
5
+ ## Own the starting experience
6
6
 
7
- Declare a session entry in the renderer plugin. Its body owns the controls, draft, pending state, and error presentation. The host supplies readiness and an operation that opens the resulting session.
7
+ A session entry owns the draft, validation feedback, submission state, and initial title for its workflow. The host owns opening the resulting session and the surrounding entry selection.
8
8
 
9
- Home displays a single available entry directly. Users choose among several entries in General settings. An explicit selection that becomes unavailable stays unresolved until the user chooses another entry. Resource templates remain available independently of the selected entry.
9
+ Choose initial resources that make the submitted work useful. A research entry might create a workspace around a source document; a conversation entry might create an Agent and accept input. Keep the entry's purpose visible rather than asking users to configure unrelated host mechanisms.
10
10
 
11
- ## Prepare and initialize
11
+ ## Separate preparation from commitment
12
12
 
13
- Use a typed plugin call for submission. Its backend implementation performs business validation and calls `plugin.createSession` with a retry key. Prepare each required resource through the supplied preparation context, using the original registered creation contract.
13
+ Preparation can perform asynchronous validation and acquire what initialization needs. The final synchronous commit establishes the session and its initial facts together. A rejected submission should not leave an apparently valid but empty piece of work behind.
14
14
 
15
- Preparation can perform asynchronous work. It returns an initial title and a synchronous initializer. The initializer creates prepared resources and writes initial records or current data through authorized object handles. Session identity, resources, initial writes, and the retry receipt commit together. A failed preparation or initializer leaves no partial session.
15
+ Use the original resource creation and action contracts when initial work has the same meaning as ordinary operations. This preserves their parsing and preparation rules instead of building a special first-use path that drifts from later use.
16
16
 
17
- When initial work uses an existing resource action contract, prepare that action against the resource token before initialization. This applies its parsing and registered preparers to the initial input as well. The pending resource has its final identity, but no persisted state yet. The owning plugin validates its initial business state and uses the prepared input in the initializer.
17
+ Observation after commitment is not a blocking initialization hook. If a resource must have state before use, make that state part of preparation and initialization rather than relying on an observer to catch up.
18
18
 
19
- Reuse the key for a retry of the same accepted submission. Keys belong to the contributing plugin. A successful retry returns the existing session without repeating preparation or initialization. A new piece of work uses a new key.
19
+ ## Keep a submission's identity
20
20
 
21
- ## Carry attachments
21
+ Treat a retry as another attempt to learn the result of the same submission, not as new work. Retain its identity and draft until acceptance is known; give a genuinely new submission a new identity.
22
22
 
23
- Obtain a renderer content input for the submission call. Pass that input as the call's content option. The backend receives a content reader separately from business input and forwards it to session creation.
23
+ This distinction matters when a response fails after the session was created. The user should be able to recover the accepted work without silently creating a duplicate session.
24
24
 
25
- Content IDs alone grant no access. Only authorized referenced bytes enter preparation and initial writes. Persisted references retain those bytes after the temporary draft closes.
25
+ Carry attachments through their content ownership boundary, separately from the business input. A content identifier alone is not access to bytes. Transfer ownership to durable state before releasing a temporary draft.
26
26
 
27
- ## Name the work
27
+ ## Name the work, not the entry
28
28
 
29
- The entry supplies the initial title. Later user or plugin title assignments append host history. Continuing from an older position restores that path's latest title, or the initial title when the path has no assignment.
30
-
31
- A paradigm can attach its own typed detail to a title assignment and implement automatic naming policy. The host preserves that detail and provides generic title operations.
29
+ Use the initial title to identify the work being started. Later naming policy may reflect its development, but belongs to the plugin or paradigm that understands that work. The host preserves title history without deciding what the work means.
@@ -1,124 +1,51 @@
1
- # Build views and settings
1
+ # Design plugin views and settings
2
2
 
3
- Views present state and accept input. Backend services own the work, results, and resource lifetime.
3
+ Views present state and accept input. Backend services own the work, results, and resource lifetime. That boundary lets an interface close or remount without changing the meaning of independent work.
4
4
 
5
- Application file services let views open resource FileRefs as byte streams and save a stream through the native Save As dialog. Pass a suggested filename and a lazy stream from the object's content reader or a file reference. Cancelling the dialog returns without reading the stream; ending the stream early abandons the transfer. Transfer failures preserve the old destination and surface as errors; views own their pending indicator and feedback. Previews and exports of captured content read the same immutable bytes.
5
+ ## Match presentation to ownership
6
6
 
7
- ## Present objects and operations
7
+ A resource card presents an object; an operation view explains one attempt to do something. An input preview may still be incomplete and is not evidence that execution began. Present final outcomes according to what actually happened, including partial effects or failure.
8
8
 
9
- A resource card shows the object's content. A tool view shows one operation, including generated input, execution progress, and the final outcome.
9
+ Use host presentation for containment and navigation. Keep the plugin's domain content within it instead of rebuilding the surrounding application. Localize the view's styling so one plugin does not redefine another's interface.
10
10
 
11
- Input previews can be incomplete. Displaying arguments does not establish that execution has begun. A final result should reflect what actually happened.
11
+ ## Give expanded views a meaningful identity
12
12
 
13
- Use host presentation facilities for the surrounding card or operation. Keep domain content within the view rather than rebuilding application navigation and containment.
13
+ An island is an expanded plugin surface with its own view lifetime. Choose its identity according to what users consider the same open work. A shared settings editor may need one instance; editors for different resources or sessions need distinct identities.
14
14
 
15
- ## Open expanded content
15
+ Base a saved editor's identity on the saved object, not an unsaved identifier field. A creation draft and a persisted object have different identities even if a user names the object “new.” After saving, normalize the draft from the accepted result rather than continuing to display a merely proposed value.
16
16
 
17
- Resource card views, settings pages, and islands can use the renderer island capability to open plugin content. Islands open at the right end of the screen and belong to the island that opened them; closing an island closes the islands it opened. Opening a key that is already open locates that island and keeps its content and ownership, so the key decides between one shared island and separate ones. Keys are unique within a screen and isolated by plugin identity; include resource, session, or parent context when distinct editors need separate keys. `has(key)` reports whether a key is open, for example to mark the selected row. The host owns ordering, sizing, and the island menu.
17
+ Opening a child view does not give it the source component's context or durable ownership. Pass the domain identity it needs explicitly and reconstruct its state from the appropriate owner. Protect unsaved edits when closing or navigating away; do not confuse a close guard with cancellation of independent backend work.
18
18
 
19
- Supply a plugin-local lookup key, accessible label, opening element, and content renderer. Choose a content surface for an editor or another view that needs more width. The host manages layout and focus. The opened view has an independent plugin region; pass its resource reference and other domain inputs explicitly rather than relying on the source component's React context or mount lifetime.
19
+ Cancellation should mean something specific to the task. An editor can abandon a draft, while a running export may need to stop I/O. Decide that outcome rather than treating every dismissal gesture as permission to terminate a service.
20
20
 
21
- For a settings editor that creates an entry and remains open for editing, bind its content key with `useRendererIslandKey`. Derive the key from the editor's current persisted identity: use a distinct creation key before the first save, then update the identity and normalized draft from the successful save result. The hook binds the new key in place, releasing the creation key so another blank editor can open. Derive it from saved identity rather than unsaved ID input; a successful rename uses the same mechanism. Keep creation and saved-object keys disjoint, including for objects named `new`.
21
+ ## Make locations reconstructable
22
22
 
23
- The island instance remains mounted with its position, width, focus, scroll, guards, and children intact. Only content lookup changes. An occupied target key is reported by the host and leaves both islands unchanged; a successful save is not rolled back or retried as creation. Imperative `bindKey` reports whether binding succeeded and applies only to ordinary islands opened by the same plugin, not an enclosing host-managed island. A key binding does not change a resource island's saved navigation destination.
23
+ A resource owns the meaning of its locations and the surfaces used to display them. Prefer a location that supplies enough domain context to reopen the same content without depending on a previous component's memory.
24
24
 
25
- Escape is not a general island close shortcut. For a cancellable task, its island owner declares one action with `useRendererIslandCancel`; pass null when the task has no cancellation action. Local controls handle Escape first, and an island without an action does not pass cancellation to its opening island. The callback owns the outcome: to dismiss the task, call the island's normal close operation so unsaved-change guards still apply. Functional windows and the shared panel frame do not declare cancellation automatically.
25
+ A reference names something; it is not an access grant or proof of current availability. Resolve it when followed and report the actual result. Keep navigation initiated by a user distinct from a model request's captured authorization scope.
26
26
 
27
- Use the island panel for its title, actions, and close control. Its fill layout lets an editor own scrolling. Mark unsaved content as dirty so closing, closure through the opening island, session navigation, and application exit ask before discarding it. A close guard can also retain a view while a save is pending. Closing the island releases its view calls without ending independent backend services.
27
+ Opening a file should preserve its meaning as file content. Text inside it does not become another application interaction contract merely because the viewer can recognize a link-like string.
28
28
 
29
- ## Open resource locations
29
+ ## Keep transfers with the right owner
30
30
 
31
- A resource type can declare `open(location, context)` in its renderer resource description. The location is an opaque string interpreted by that resource. A file resource can open an editor or read-only viewer; a browser resource can navigate to a URL. The handler receives the resolved resource reference, typed calls, the opening element, and an island capability bound to the target plugin. It returns whether the open completed. The first island a handler opens for a navigation is restorable: the host saves the resource and location and calls the handler again to rebuild that island when the session reopens, so the handler should derive the island from the location alone.
31
+ Use immutable retained content when a preview and an export must refer to exactly the same bytes. A file reference is more appropriate when the intent is to resolve content at consumption time. Make that choice before presenting the transfer as a saved result.
32
32
 
33
- Use `useRendererResourceNavigation().open(resource, location, { origin })` from a card, settings page, Home entry, or island. Supply the session ID and resource ID. The host resolves current resource presence and invokes its registered handler. It reports missing resources, unsupported opening, and handler failures. User and plugin navigation are independent of model-request authorization and directed resource links.
33
+ The view owns pending indicators and feedback for a transfer it starts. Its cancellation signal should stop that transfer, not unrelated readers or the resource's independent services. Treat an unavailable source or failed transfer as a failure, not as empty content.
34
34
 
35
- Resources own the meaning of their locations and their content surfaces. A filename remains a file location; opening it does not turn its contents into application navigation or grant embedded text another interaction contract. Directory files use editable text and image surfaces, while manual files use read-only text and image surfaces.
35
+ ## Separate settings drafts from shared configuration
36
36
 
37
- A reference URL is a string that names something to act on: `resource:<encoded resource ID>/<location>` addresses a resource location, and `skill:<encoded name>[/<package path>]` addresses a skill in the Agent skill catalog. Location segments are percent-encoded individually and keep `/` as a separator. `resourceUrl`, `skillUrl`, and their `parse*` counterparts build and read them; `referenceMarkdown(label, url)` writes the Markdown link form. A reference URL is only text: it can name a resource that is absent, removed, or not linked to anyone, and following it reports what it finds at that time. A displaying interface supplies the session identity when following a resource URL. The Agent Markdown interface recognizes both schemes.
37
+ A settings page owns its edit draft and interaction state; the backend owns shared configuration. Closing the page ends view subscriptions, not every service affected by the settings.
38
38
 
39
- Any view can start a reference drag. In `dragstart`, call `setReferenceDrag(event.dataTransfer, text)` with reference text, usually one or more `referenceMarkdown` links. The drag carries only the `application/vnd.asterism.reference` type, so surfaces that do not read references, including the canvas, ignore it. Targets check `hasReferenceDrag` during `dragover` and read the text with `readReferenceDrag` on `drop`. The Agent composer inserts dropped reference text at the drop point, where resource and skill links become chips.
39
+ Choose managed configuration for schema-validated settings. Other domain data may need a different persistence model. Avoid treating every editable value as configuration simply because it appears on a settings page.
40
40
 
41
- ## Style plugin views
41
+ ## Offer commands as focused interactions
42
42
 
43
- Import CSS from the renderer entry or its components. Asterism builds the imported styles and loads them before frontend preparation and view registration. CSS references to bundled images and fonts keep their relative paths. Style loading failures appear as frontend plugin failures.
43
+ Use the application palette for actions and controls that are useful without opening a full editor. Decide whether an inapplicable action should be absent or whether a temporarily unavailable action should remain visible with a reason.
44
44
 
45
- Use CSS Modules (`.module.css`) for component-local class names, importing the generated names into the component. Plain CSS shares the application's document, so global selectors and resets affect other views. Host theme variables can supply colors and spacing without redefining the application theme.
45
+ An asynchronous command owns its pending and failure state. Close its interface when the intended result is known, not merely when work was dispatched. Backend work still uses the plugin's ordinary communication and authorization boundaries.
46
46
 
47
- Tailwind and other preprocessors belong to the plugin's build setup. Generate ordinary CSS and import that output; the host does not process the plugin's Tailwind or PostCSS configuration. Utility classes used only by an external plugin need its own generated CSS.
47
+ For example, a compact-row preference and a reset action should address the same preference. The palette is another interaction surface, not a second store. A real control should own its input interaction rather than masquerading as an action row.
48
48
 
49
- Styles remain loaded while the plugin frontend is active, including when individual cards unmount. Failed initialization releases that plugin's stylesheet; ending the frontend lifetime releases all loaded plugin styles.
49
+ ## Keep language independent of work
50
50
 
51
- ## Add settings
52
-
53
- A plugin can declare several settings pages independently of sessions and resources. Each has its own identity, title, summary, optional icon, and body. The icon is a component the host draws at its own size and color; the host draws the card, page heading, and attribution, and the plugin supplies only the body. Entries appear on settings home with the contributing plugin's display name. Plugin management is a separate list for installation and enablement.
54
-
55
- The page owns its edit drafts and pending interactions; the plugin service owns shared configuration. Navigation targets a plugin and page, with an optional declared location inside the page. A page failure is isolated and can be retried without disabling other settings pages.
56
-
57
- Managed configuration suits schema-validated settings. Other plugin data can use a storage model appropriate to its purpose.
58
-
59
- Closing a page releases its view subscriptions. It does not end every service the plugin uses.
60
-
61
- ## Contribute application commands
62
-
63
- Declare command groups in the renderer plugin's `commands` field. The application palette displays each group as **Plugin name · Group**, keeping groups separate even when different plugins use the same label. Group IDs are local to the plugin; command IDs are local to the group.
64
-
65
- Each group's `useCommands(context)` is a React hook, mounted in that plugin's calls and preferences scope while the palette is open. Call hooks unconditionally, then use `when: false` to hide commands that do not apply. `disabled: true` keeps an unavailable command visible. The context supplies the current session snapshot, or null outside a session, and whether that session is ready for operations. A session command can hide when no session exists and disable while it is not ready.
66
-
67
- An action uses `onAction`; it decides when to dismiss the palette through `context.close()`. For asynchronous work, retain pending and failure state in the hook, disable reentry, show feedback in `detail`, and close after success. Invoke backend work through ordinary typed plugin calls, passing session identity explicitly when needed. Renderer commands need no separate backend registry.
68
-
69
- A control uses `control` instead of `onAction`. It is a real interactive child, such as an input, switch, or select, rather than an action row that activates around it. Its component owns its interaction and may use plugin-scoped hooks. Compose controls from the plugin's own UI components; the command contract does not require a UI library.
70
-
71
- For example, a plugin can combine a persistent preference control with a reset action:
72
-
73
- ```tsx
74
- import { useState } from "react";
75
- import { z } from "zod";
76
- import {
77
- defineRendererPlugin, useRendererPreferences,
78
- type RendererCommandGroup,
79
- } from "@asterism-app/sdk/renderer";
80
-
81
- function CompactRows() {
82
- const preferences = useRendererPreferences();
83
- const [compact, setCompact] = useState(
84
- () => preferences.get("compactRows", z.boolean()) ?? false,
85
- );
86
- return <input type="checkbox" aria-label="Compact rows" checked={compact}
87
- onChange={event => {
88
- const next = event.currentTarget.checked;
89
- preferences.set("compactRows", next);
90
- setCompact(next);
91
- }} />;
92
- }
93
-
94
- const appearance: RendererCommandGroup = {
95
- id: "appearance", label: "Appearance",
96
- useCommands({ close }) {
97
- const preferences = useRendererPreferences();
98
- return [
99
- { id: "compact", label: "Compact rows", control: <CompactRows /> },
100
- {
101
- id: "reset", label: "Reset row spacing",
102
- onAction() {
103
- preferences.set("compactRows", null);
104
- close();
105
- },
106
- },
107
- ];
108
- },
109
- };
110
-
111
- export default defineRendererPlugin({ commands: [appearance] });
112
- ```
113
-
114
- ## Start work from Home
115
-
116
- A session entry supplies the complete starting interface for a plugin's workflow. It owns drafts, validation feedback, submission, and the initial title. Submit through a typed plugin call, prepare resources in the backend, and initialize the session atomically. Open the resulting session using the entry's host-provided callback.
117
-
118
- Keep a retry identity until submission succeeds. Attachments travel through the call's content capability independently of its JSON input. The host handles entry selection and retains access to templates when no entry is available.
119
-
120
- ## Write interface text
121
-
122
- Plain text is valid. Message declarations and translation catalogs support plugins that need localized interfaces.
123
-
124
- Keep protocol identifiers, code, and raw diagnostics distinct from interface explanations. UI language changes should not reset drafts or running work.
51
+ Localize interface explanations without changing protocol identifiers, user content, or raw diagnostics. Changing the UI language should not reset drafts or running operations. Keep translation choices in presentation rather than making business state depend on rendered text.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@asterism-app/sdk",
3
- "version": "1.10.1",
3
+ "version": "1.11.0",
4
4
  "description": "Public contracts and host capabilities for Asterism plugins",
5
5
  "license": "MIT",
6
6
  "author": "Chien Zhang",
@@ -9,6 +9,11 @@ export const catalogModelSchema = z.object({
9
9
  generation: z.object({ maxOutputTokens: z.number().nullable() }),
10
10
  capabilities: z.object({ reasoning: z.boolean(), tools: z.boolean(), thinkingLevels: z.array(thinkingSchema) }),
11
11
  });
12
+ /** Enabled model metadata available to runtime consumers; model is the complete provider/model expression. */
13
+ export const modelInfoSchema = catalogModelSchema.omit({ providerId: true, modelId: true, enabled: true }).extend({
14
+ provider: z.string(), model: z.string(),
15
+ });
16
+ export type ModelInfo = z.infer<typeof modelInfoSchema>;
12
17
  /** Configured model metadata for plugin selectors and diagnostics; credentials remain backend capabilities. */
13
18
  export const ModelCatalog = defineData("asterism.models/catalog", z.object({
14
19
  modelProviders: z.array(z.object({ id: z.string(), name: z.string(), enabled: z.boolean() })),
package/src/models.ts CHANGED
@@ -1,5 +1,6 @@
1
1
  /** Shared model protocol: independent of resource implementations, agent configuration, and host adapters. */
2
2
  import type { Json } from "./json.ts";
3
+ import type { ModelInfo } from "./model-catalog.ts";
3
4
  import type { ModelInputPart } from "./model-input.ts";
4
5
  import type { ContentReader } from "./content-runtime.ts";
5
6
  import type { ToolOutcome, ToolInvocationInfo, ToolResult } from "./tool-result.ts";
@@ -72,7 +73,9 @@ export type ModelLiveBlock = { id: string; responseId: string; ordinal: number }
72
73
  | { kind: "thinking"; text: string; startedAt: number; endedAt: number | null }
73
74
  /** During the input phase, arguments is a display preview parsed tolerantly and cannot be used for execution; other phases contain complete arguments. */
74
75
  | { kind: "toolcall"; name: string; argumentsText: string; arguments: Json; state: "input" | "ready" | "executing";
75
- invocation: ToolInvocationInfo | null; result: Extract<ToolResult, { kind: "running" }> | null }
76
+ invocation: ToolInvocationInfo | null; result: Extract<ToolResult, { kind: "running" }> | null;
77
+ /** One-shot attention time, present only in live execution; history does not replay notices. */
78
+ noticeAt?: number }
76
79
  );
77
80
  export type ModelRunEvent =
78
81
  | { type: "block"; block: ModelBlock }
@@ -101,6 +104,8 @@ export interface ModelToolCall { callId: string; name: string; arguments: Json }
101
104
  export interface ModelToolObserver {
102
105
  prepared?(call: ModelToolCall, info: ToolInvocationInfo): void;
103
106
  started?(call: ModelToolCall, info: ToolInvocationInfo): void;
107
+ /** An accepted invocation requested attention at execution start, independently of its progress or completion. */
108
+ noticed?(call: ModelToolCall): void;
104
109
  published?(call: ModelToolCall, data: Json): void;
105
110
  }
106
111
  /** Executable tools supplied by the requesting paradigm or a host-bound request environment. */
@@ -150,5 +155,6 @@ export interface ModelServices {
150
155
  stream(request: StreamRequest, options?: ModelInputOptions): AsyncIterable<ModelEvent>;
151
156
  /** One request and its tool batch; neither saves history nor drives the next request. */
152
157
  run(request: ModelRunRequest, options?: ModelInputOptions): Promise<ModelRunResult>;
153
- list(): readonly { model: string; provider: string; name: string; contextWindow: number | null; capabilities: { reasoning: boolean; tools: boolean; thinkingLevels: readonly ThinkingLevel[] } }[];
158
+ /** Current configured metadata for models whose model and provider are enabled; listing does not probe credentials or connectivity. */
159
+ list(): readonly ModelInfo[];
154
160
  }
@@ -20,6 +20,12 @@ export interface ToolContract<A extends ToolInput = ToolInput> extends ContractR
20
20
  argsSchema: z.ZodType<A>;
21
21
  /** Execution requires an endpoint that can receive user interaction. Output rendering alone does not require it. */
22
22
  requiresInteraction?: boolean;
23
+ /**
24
+ * Each validated invocation requests user attention once when execution starts, independently of interaction endpoint requirements.
25
+ * The host publishes an awaiting reminder for the caller and exposes a transient live-call highlight. Viewing consumes the reminder;
26
+ * the notice does not change execution state or track unresolved business work.
27
+ */
28
+ requiresNotice?: boolean;
23
29
  }
24
30
  /** Tool definitions fix selection descriptions, usage guidance, and args; implementations add only target/result and execution information. */
25
31
  export interface ImplementationContract<S extends Json, T extends ToolInput, A extends ToolInput, O extends Json> extends DataContract<O> {
@@ -61,6 +61,27 @@ export function primaryQuota(items: readonly UsageItem[]): QuotaItem | null {
61
61
  return selected;
62
62
  }
63
63
 
64
+ /**
65
+ * Availability that every usage consumer presents the same way. Exhausted means a request cannot succeed: a window at zero or a
66
+ * balance at or below zero. Low compares the bare number, so balance depletion reads the same whatever its unit.
67
+ */
68
+ export type UsageLevel = "available" | "low" | "exhausted";
69
+ const lowQuotaShare = 0.25, lowBalance = 10;
70
+ const levelRank: Record<UsageLevel, number> = { available: 0, low: 1, exhausted: 2 };
71
+ export function usageItemLevel(item: UsageItem): UsageLevel {
72
+ const [value, low] = item.type === "quota" ? [quotaRemaining(item), lowQuotaShare] : [item.remaining, lowBalance];
73
+ return value <= 0 ? "exhausted" : value < low ? "low" : "available";
74
+ }
75
+ /** The most constrained item decides; null when nothing is reported. */
76
+ export function usageLevel(items: readonly UsageItem[]): UsageLevel | null {
77
+ let level: UsageLevel | null = null;
78
+ for (const item of items) {
79
+ const next = usageItemLevel(item);
80
+ if (!level || levelRank[next] > levelRank[level]) level = next;
81
+ }
82
+ return level;
83
+ }
84
+
64
85
  export type UsagePeriodUnit = "year" | "month" | "week" | "day" | "hour" | "minute" | "second";
65
86
  const periodUnits: readonly [UsagePeriodUnit, number][] = [
66
87
  ["year", 31_536_000], ["month", 2_592_000], ["week", 604_800], ["day", 86_400], ["hour", 3_600], ["minute", 60],
@@ -45,6 +45,8 @@ export interface RendererIsland {
45
45
  export interface RendererIslandPanelProps {
46
46
  title: string;
47
47
  description?: string;
48
+ /** What the content belongs to, shown before the title, such as a reference chip for its resource or skill. */
49
+ source?: ReactNode;
48
50
  /** Primary title bar action, such as save. */
49
51
  action?: ReactNode;
50
52
  /** Fixed toolbar below the title bar, such as search. */
@@ -14,7 +14,12 @@ export interface RendererResourceOpenContext extends RendererResourceOpenOptions
14
14
 
15
15
  export type RendererResourceOpener = (location: string, context: RendererResourceOpenContext) => boolean | Promise<boolean>;
16
16
 
17
+ /** Current identity and title of a present resource; kind selects its presentation through useRendererResources. */
18
+ export interface RendererResourceIdentity { readonly ref: ResourceRef; readonly title: string }
19
+
17
20
  export interface RendererResourceNavigation {
21
+ /** Read the resource's current identity and title at call time; null when the session or resource is absent. Other failures reject. */
22
+ resolve(resource: Pick<ResourceRef, "sessionId" | "id">): Promise<RendererResourceIdentity | null>;
18
23
  /** Resolve current presence without model-request authorization. Failures are shown by the host; a cancelled open returns false. */
19
24
  open(resource: Pick<ResourceRef, "sessionId" | "id">, location: string, options?: RendererResourceOpenOptions): Promise<boolean>;
20
25
  }
@@ -12,7 +12,7 @@ import type { EventContract, PluginEvents } from "./events.ts";
12
12
  import type { ToolCompletion, ToolInvocationInfo, ToolModelOutput } from "./tool-result.ts";
13
13
  import type { PluginConfig, PluginLogger, PluginSecrets, PluginTasks } from "./runtime.ts";
14
14
  import type { ModelServices } from "./models.ts";
15
- import type { ResourceSnapshot, SessionSnapshot, SessionDirectory } from "./workspace.ts";
15
+ import type { ResourceRef, ResourceSnapshot, SessionSnapshot, SessionDirectory } from "./workspace.ts";
16
16
  import type { ActionContract, CreationContract } from "./commands.ts";
17
17
  import type { ObjectReader, ObjectExecutor, SessionExecutor } from "./objects.ts";
18
18
  import type { ContentReader, ContentScope } from "./content-runtime.ts";
@@ -116,6 +116,11 @@ export interface ActionContribution {
116
116
  prepare?(input: Json, context: ActionPreparation): Preparation | Promise<Preparation>;
117
117
  execute(input: Json, object: ObjectExecutor, signal: AbortSignal): Promise<void>;
118
118
  }
119
+ /** A live runtime instance whose termination needs user confirmation. */
120
+ export interface ResourceDisposalWarning {
121
+ readonly resource: ResourceRef;
122
+ readonly warning: UiText;
123
+ }
119
124
  export interface ResourceContribution {
120
125
  readonly resource: ResourceContract;
121
126
  /** Geometry declarations for backend placement, shared with ResourceDescription and cardRenderer. */
@@ -136,8 +141,11 @@ export interface ResourceContribution {
136
141
  context?(resource: ResourceSnapshot, object: ObjectReader): Promise<ContextFile[]>;
137
142
  /** Resolve a file address against this resource at consumption time; consumers need no link or registration of the reference. */
138
143
  openFile?(resource: ResourceSnapshot, locator: Json, context: { object: ObjectReader; signal: AbortSignal }): AsyncIterable<Uint8Array>;
139
- /** Explanation presented to users before ending the current instance; does not block backend removal or wait for external cleanup. */
140
- disposalWarning?(resource: ResourceSnapshot, object: ObjectReader): UiText | null;
144
+ /**
145
+ * Enumerate warnings from this backend's live instances without restoring saved resources.
146
+ * The host selects affected identities and resolves their current titles. Does not perform cleanup.
147
+ */
148
+ disposalWarnings?(): readonly ResourceDisposalWarning[];
141
149
  /**
142
150
  * Called synchronously when an object enters the current set through startup, creation, restoration, or rewinding.
143
151
  * Removal ends discovery and cancels owned tasks/model requests immediately; attachment lifetime cleanup follows captured request holds.
@@ -48,7 +48,7 @@ export function implementResource<S extends Json, V extends Json>(
48
48
  inspect(data: NoInfer<S>, object: ObjectReader): Promise<Json>;
49
49
  context?(data: NoInfer<S>, object: ObjectReader): Promise<ContextFile[]>;
50
50
  openFile?(data: NoInfer<S>, locator: Json, context: { object: ObjectReader; signal: AbortSignal }): AsyncIterable<Uint8Array>;
51
- disposalWarning?(data: NoInfer<S>, object: ObjectReader): import("./i18n.ts").UiText | null;
51
+ disposalWarnings?: ResourceContribution["disposalWarnings"];
52
52
  /** Called when an object enters the current set; external instances owned exclusively by the object register cleanup with lifetime. */
53
53
  attach?(data: NoInfer<S>, object: ObjectReader, lifetime: Lifetime): void;
54
54
  },
@@ -62,7 +62,7 @@ export function implementResource<S extends Json, V extends Json>(
62
62
  context: async (snapshot, object) => definition.context?.(parse(resource.stateSchema, snapshot.data, "resource"), object) ?? [],
63
63
  ...(openFile ? { openFile: (snapshot: ResourceSnapshot, locator: Json, context: { object: ObjectReader; signal: AbortSignal }) =>
64
64
  openFile(parse(resource.stateSchema, snapshot.data, "resource"), locator, context) } : {}),
65
- disposalWarning: (snapshot, object) => definition.disposalWarning?.(parse(resource.stateSchema, snapshot.data, "resource"), object) ?? null,
65
+ disposalWarnings: definition.disposalWarnings,
66
66
  ...(attach ? { attach: (snapshot: Parameters<NonNullable<ResourceContribution["attach"]>>[0], object: ObjectReader, lifetime: Lifetime) =>
67
67
  attach(parse(resource.stateSchema, snapshot.data, "resource"), object, lifetime) } : {}),
68
68
  };