@asterism-app/sdk 1.10.2 → 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.
package/README.md CHANGED
@@ -1,21 +1,21 @@
1
1
  # Asterism SDK
2
2
 
3
- The SDK defines the shared language between Asterism and plugins: contracts, host capabilities, and contributions.
3
+ The SDK is the shared boundary between Asterism and plugins. It supplies generic hosting capabilities while plugins own the meaning of their resources and workflows. Agent conversation and other paradigm-specific behavior belong to the plugin that implements them.
4
4
 
5
- Pure declarations can be shared across execution environments. Backend interfaces support work and persistence; frontend interfaces support presentation and interaction.
5
+ ## Design against a shared boundary
6
6
 
7
- The SDK describes generic mechanisms. Agent conversation, naming, and other domain behavior belong to the plugin that implements them.
7
+ Use public contracts to share meaning without importing another implementation. Their runtime identity matters as well as their TypeScript shape. Public abstractions should express capabilities consumers need, not reproduce internal decomposition.
8
8
 
9
- Public interfaces should express a capability an author needs. Internal decomposition is not itself a reason to expose another abstraction.
9
+ Keep backend work and frontend presentation separate while making each capability's ownership understandable. The host composes contributions; it does not infer domain behavior from a plugin's private state.
10
10
 
11
- ## Installation
11
+ ## Develop for the target application
12
12
 
13
- Install with `npm install --save-dev --save-exact @asterism-app/sdk@latest` to target the stable application, or `@next` to target the preview application. Declare `@asterism-app/sdk` as a peer dependency with `"*"` in the plugin package.
13
+ Use a compatible SDK version for development and treat the running application as the runtime provider. Development dependencies supply declarations; peer dependencies express the host-provided relationship. Installing a newer SDK does not upgrade the application's capabilities.
14
14
 
15
- The package ships TypeScript source. Asterism compiles plugin entries and supplies its own SDK instance at runtime. Use declarations compatible with the target application; installing a newer SDK does not update the application's APIs.
15
+ Validate both contract agreement and actual integration. Type checking cannot establish that a distributed plugin includes all required assets, works in the intended application, or releases the work it owns.
16
16
 
17
- ## Authoring material
17
+ ## Keep authoring material purposeful
18
18
 
19
- The source package includes `docs/` for plugin development guides and `examples/` for public API usage. `examples/counter/` is a complete starter package; the other examples are focused fragments to compose into a plugin. The application's manual exposes these directories directly.
19
+ The package includes prose guides and maintained source examples. Guides explain mental models, ownership, integration choices, and working principles; public declarations and examples carry concrete interfaces and assembly. The complete counter package provides a small design to adapt, not a required architecture for every plugin.
20
20
 
21
- Examples participate in repository type checking. Internal compile-time counterexamples live in `typechecks/` and are excluded from package contents and the manual. Built-in domain guides and examples belong to `@asterism-app/builtin-api`.
21
+ These materials support software use and plugin development on demand. Runtime tool descriptions, guidelines, and schemas own tool invocation knowledge independently of the manual.
@@ -1,133 +1,61 @@
1
1
  # Manage data and lifecycle
2
2
 
3
- Choose storage from the meaning of the data. Latest values, historical facts, immutable bytes, and running processes have different lifetimes.
3
+ Choose storage from the meaning of the data. Latest values, historical facts, immutable bytes, and running processes answer different questions and need different owners.
4
4
 
5
5
  ## Separate current state from history
6
6
 
7
- Current data records the latest session or object value. Historical records preserve facts needed to understand or reconstruct past work.
7
+ Current data answers what is true now. History explains what happened. Saving a current value is not a promise that browsing history will restore it; restoration needs a domain operation with a defined meaning.
8
8
 
9
- Saving a current value does not automatically create history. Moving to an earlier history position does not restore that value. A resource that supports restoration defines the facts and operations that make restoration meaningful.
9
+ For example, a counter can keep its latest value while recording each increment for explanation. A document editor may instead need a restorable body at each revision. Decide which experience the resource promises before choosing its records and current data.
10
10
 
11
- Plugin-wide private data belongs to the plugin. Temporary interface choices belong to a view or an object-retained view scope, according to how long they should survive.
11
+ Keep plugin-wide private data with the plugin. Keep temporary interface choices with the view unless users need them to survive reopening. A running process is neither saved data nor a historical fact: it needs a live owner and cleanup.
12
12
 
13
- ## Encode data at boundaries
13
+ ## Treat encoding as a domain boundary
14
14
 
15
- Data schemas describe the values used by plugin code and how they are decoded from stored or transported JSON. Writers, resource creation, tool results, and presentations accept the decoded value and encode it before storage or publication. Typed readers and views decode the saved value.
15
+ Use a codec when the value plugin code works with differs from its stored representation. Keep conversion semantics with that declaration rather than scattering normalization through readers and writers. A one-way input transformation and a reversible storage conversion solve different problems.
16
16
 
17
- Use an ordinary Zod schema when both representations are the same. Use a synchronous `z.codec` when they differ. Both the domain value and its encoding remain JSON-compatible. One-way `.transform()` belongs in input preparation or an explicit conversion before writing; Zod cannot encode it in reverse.
17
+ Check meaningful round trips for custom conversions. In particular, reading an old representation and writing a new one should preserve the domain value even when their JSON differs. Compatibility decoding can make an old fact readable without rewriting what was originally recorded.
18
18
 
19
- Resource creation returns a card title and plugin-owned `data`. State can be any JSON value, including arrays, scalars, or `null`; object fields such as `id`, `type`, and `title` retain their business meaning. The host stores resource identity and card title separately. Renaming a card changes its host title, and creating resources from a template gives them new host identities while preserving the encoded plugin state.
19
+ Separate host identity and presentation from business state. A domain field named “title” need not be the card title, and a domain identifier need not be the host resource identity. Conflating them makes renaming and reuse surprising.
20
20
 
21
- Configuration defaults are complete decoded values. Reading an older configuration may fill absent fields through ordinary `.default()` declarations. Configuration updates receive decoded values, and saving an unchanged value preserves a correctly defined codec's domain value. The host handles encoding of configuration files and frontend responses.
21
+ ## Decide what a template can reuse
22
22
 
23
- Codecs own their conversion semantics. Verify meaningful round trips when supplying custom encoders, decoders, or normalization callbacks. Tool results reserve `null` for absent output, so a non-null tool value needs a non-null encoding.
23
+ A data-copy template is appropriate when selected saved values remain meaningful under new host identities. A note can reuse its body; an Agent can reuse configuration without carrying pending work into a new session.
24
24
 
25
- ## Reuse resources in templates
25
+ Treat copying an address differently from cloning what it addresses. A resource that depends on an external account, embedded object identities, or private files may need an explicit domain-specific cloning operation instead of a data-copy template. Such an operation can explain what will be shared, copied, or reconnected.
26
26
 
27
- A resource opts into data-copy templates with `template: { current: [Settings, Content] }` in its implementation. The list contains existing data contracts owned by the resource's plugin. An empty list copies only the resource's creation state. Resources without this declaration remain available for ordinary use and do not appear in the template picker.
27
+ Choose titles according to the same distinction. Preserving a descriptive source title can help users recognize a reusable setup; generating a title can make sense when each instance represents new work.
28
28
 
29
- Templates retain encoded creation state and the listed current values that exist at save time. Unlisted current data, history, private files, and running instances are excluded. Instantiation creates new host identities and remaps host links; it preserves domain values and content references without rewriting embedded resource IDs or duplicating external services. Creation callbacks are not rerun, and ordinary presence lifetimes apply to the new objects.
29
+ ## Commit facts, then observe them
30
30
 
31
- To give each template instance a new title, add a synchronous `createTitle(): string` function to the resource's `template` declaration. Saving then omits the source title, including a user-assigned title. The host calls the function once for each new object when instantiating a template, and uses its result even if an older template contains a title. Saving and previewing templates do not call it. Without this function, templates preserve source titles; a saved entry without a title requires the generator to remain available.
31
+ Complete network and file processing outside synchronous transactions, then commit the resulting state. Keep the commit focused on the facts that must become visible together.
32
32
 
33
- Opt in when those copied values are reusable under new identities. For example, a note can retain its body, and an agent can retain its configuration while leaving submission receipts and drafts behind. Resources needing external cloning, reference mapping, or private-state reconstruction need an explicit domain operation. Historical observation does not perform restoration.
33
+ Use a pending operation record when consumers need to know about work before its result exists. Its identity represents one operation from published input to final outcome. Keep progress transient unless it has lasting domain meaning, and assign responsibility for ending abandoned work to the owner that started it.
34
34
 
35
- The installed resource must still support templates and decode all saved state and selected current data when the template is used. Unsupported or invalid saved entries fail explicitly before a new session is created.
35
+ A snapshot fixes the evidence being read; it does not redirect later writes into the past. Reuse one snapshot for related queries when their conclusions need a common basis. Obtain a fresh one when the question is about current state.
36
36
 
37
- ## Commit and observe
37
+ Notifications are prompts to observe, not substitutes for saved state. A state-driven consumer should subscribe and read the current value, then reread when notified. An occurrence-driven consumer must decide whether missing an event during downtime is acceptable or whether the domain needs durable records.
38
38
 
39
- Use the host's bound read and execution capabilities. Complete network and file processing outside synchronous transactions, then commit the resulting state.
39
+ ## Read history through its owner
40
40
 
41
- A historical snapshot fixes what is observed. A later write acts in the current execution context. Holding a snapshot does not redirect later writes into the past.
41
+ Import the original public record contract rather than interpreting another domain's JSON by convention. Shared decoding keeps the meaning and compatibility policy with the author who owns the fact.
42
42
 
43
- For an operation that other consumers must discover before it finishes, declare an operation record with input and output schemas. Begin it in a synchronous commit to publish the input and obtain its record ID. Complete that ID in a later commit with the output. This fills the result at its original position without moving the cursor. The result can be filled once; input and record identity remain fixed.
43
+ Unreadable evidence is different from absent evidence. Preserve that distinction when reporting or deciding whether to recover. A failed transfer is also not an empty query result. An interface should expose those differences rather than presenting an apparently complete account.
44
44
 
45
- The record's pending flag distinguishes an unresolved operation from a completed operation whose output is null. Existing snapshots keep their original pending observation; read a new snapshot for current results. Every timeline path containing the operation can read its result, even if another path was selected when it completed.
45
+ Distinguish a creation fact from current presence. Reconstructing an object while browsing history does not mean it was just created. Use historical observation to react to committed facts and attachment lifetimes to own work while a resource is present.
46
46
 
47
- An object writer can complete that object's pending records. A session writer can finish records owned by its plugin after the emitting object leaves the current path. Completion emits a separate observer notification, not a new-record notification. Resource implementations retain responsibility for ending abandoned work rather than waiting for a runtime that no longer exists.
47
+ ## Choose between an address and preserved bytes
48
48
 
49
- Transient events announce change. A consumer needing current state establishes its subscription and reads the current value; later notifications prompt another read.
49
+ A file reference is an address interpreted by its source resource. It is useful when a consumer should decide whether and when to read external content. Passing the address does not preserve a version of that content.
50
50
 
51
- The host publishes `SystemResumed` when the operating system resumes from sleep. Subscribe through `plugin.ipc.events` with the plugin lifetime signal when maintaining absolute deadlines or other state affected by elapsed sleep time. Re-evaluate against the current wall clock when handling the event. It is a transient occurrence and is not replayed after application startup.
51
+ Retained immutable content is appropriate when a record, attachment, or export must continue to mean the same bytes. For example, a reference to a working file suits “review the current draft”; a retained attachment suits “explain the draft that was submitted.”
52
52
 
53
- Typed calls describe request and response values with ordinary Zod schemas. The caller supplies the input schema's input; the implementation receives its parsed output, including defaults. The implementation returns JSON accepted by the output schema, and the caller receives that schema's parsed output. These types are inferred from the shared declaration, so a conversion such as string to number does not require separate type annotations.
53
+ Content identifiers alone are not ownership or access. Preserve retained references in the saved encoding, and transfer ownership before closing temporary content scopes. A reference synthesized only while decoding cannot preserve bytes that were never retained.
54
54
 
55
- ## Read typed history
55
+ ## End work with its owner
56
56
 
57
- Public record contracts belong to the package that owns their meaning. The SDK exposes host resource creation, renaming, removal, and link changes. A paradigm's public API supplies its conversation records; a plugin's public package supplies its business records. Import the original contract to decode a record rather than interpreting its JSON fields yourself.
57
+ Bind shared services to the plugin lifetime and object-owned work to the resource lifetime. Register cleanup when creating the work, while its ownership is clear. Pass cancellation into the I/O it controls and wait for actual completion before releasing dependencies that work still uses.
58
58
 
59
- Use `contract.decode(record)` for a single record and `contract.decodeAll(records)` for a commit batch. Batch decoding preserves the supplied order and omits records belonging to other contracts. A matching record returns either `known` with typed `data`, or `unknown` with the original `record` and an invalid-data reason. An unreadable matching record remains visible for reporting and recovery decisions.
59
+ Use timeline activity tracking for work whose writes depend on the current history position. An external service may need to stop when its resource disappears without otherwise preventing history navigation. Choose based on that dependency, not merely on whether the operation is asynchronous.
60
60
 
61
- ```ts
62
- import { ResourceCreated } from "@asterism-app/sdk/contracts";
63
-
64
- for (const created of ResourceCreated.decodeAll(records)) {
65
- if (created.status === "unknown") {
66
- reportUnreadable(created.record);
67
- continue;
68
- }
69
- handleCreation(created.data, created.record.sessionId);
70
- }
71
- ```
72
-
73
- For stored history, use `snapshot.records.query(ResourceCreated, { scope: "timeline" })`; it returns the same decoded result shape. `first` and `last` select the earliest or latest matching record and preserve `unknown` when that selected record is unreadable. `timeline` selects the snapshot's ancestor path; `session` includes other branches within its captured append bound. These reads retain original record identity and do not rewrite stored data.
74
-
75
- Use `records.index` when only identity, ancestry, order, contract, or provenance is needed. It returns metadata without reading bodies. Queries can combine contracts, record IDs, and an emitting resource ID. `source: null` selects records without an emitting resource. `from` includes its anchor and `before` excludes its anchor; both anchors must belong to the selected scope before filters are applied. `limit` selects a bounded page, and `edge: "last"` selects the last matches while still returning them in append order. A preceding page ends before the first record of the current page.
76
-
77
- Query filters intersect, including a typed reader's contract and any supplied contract filter. Repeating a contract or record identity does not duplicate results.
78
-
79
- Runtime snapshots read synchronously. Renderer snapshots share the same query semantics, with synchronous metadata and asynchronous body and resource reads. Await those reads before decoding or projecting data. React views can use `useSessionRead` with a memoized reader to distinguish loading, ready, and error states. Forward its cancellation signal to reads so closing a view stops further pages without cancelling other readers of the same body. A failed transfer is not an empty result or an unreadable record. Reuse the session snapshot across related queries; finalized bodies are shared across views, while pending bodies retain their original observation.
80
-
81
- The reading hook supplies `retry()` for rereading the current query. `keepPrevious` retains visible content while the same logical query refreshes along its timeline. A `key` identifies that query when the reader callback also depends on presentation inputs; changing the selected record or query scope uses a different key so content from the previous selection is not shown.
82
-
83
- A creation record separates resource identity, type, title, and encoded resource state. Its `type` is the resource kind. The nested `data` remains JSON because resource kinds have different state contracts; match the resource kind and decode that state with its resource contract when needed. To read a resource present in a snapshot, use `snapshot.resources.get(resourceContract, id)`. Private current-data entries remain owned by their declaring plugin.
84
-
85
- Creation records include new identities instantiated from templates. Moving through history may make an existing resource appear again without creating a new record. Record observers report committed facts; presence events and attachment lifetimes describe membership in the current resource set. A host-created resource record has a null source, with the associated resource identity in its payload.
86
-
87
- Public history contracts provide typed observation. Create, rename, remove, and link resources through the session operations; plugin record writers retain their existing ownership checks.
88
-
89
- ## Retain file content
90
-
91
- Stage immutable bytes through the content service, then store their reference in persistent data or a record that owns them.
92
-
93
- A `ContentRef` identifies stored immutable content. Copying its identifier does not by itself grant access or retain the bytes. Pass it through the supported operation scope so ownership remains explicit.
94
-
95
- Retention follows references in the JSON actually saved. Preserve content references in that encoding when their bytes must remain available; synthesizing a reference during decoding does not retain content or grant access.
96
-
97
- When completing an operation with attachments from an independent temporary scope, supply that scope's content reader. The host validates access and retains those result references in the same transaction as completion. Input references remain retained. Close the temporary scope after completion has committed.
98
-
99
- ## Pass resource file references
100
-
101
- Use a `FileRef` to pass an address without reading or retaining content. It contains the full source resource identity and a JSON locator interpreted by that resource. Construct it directly and include it in tool results, typed calls, events, or saved state. No registration, content scope, or consumer link is required.
102
-
103
- The source resource implements `openFile` to interpret its locator and produce an asynchronous byte stream. A consumer uses `plugin.files.open(ref, { signal })` and processes chunks as they arrive. Breaking iteration closes the stream. Forward an operation's cancellation signal so its consumption stops with that operation.
104
-
105
- Reuse `fileRefSchema` in contracts that return or accept these addresses. Its description supplies the shared meaning. Describe each operation's own use of the reference without coupling its instructions to particular producer or consumer resource types.
106
-
107
- Discovery returns addresses and descriptive metadata; it need not open files. Each consumption resolves the source anew across sessions, independently of open UI surfaces. The host does not cache bytes or freeze external files. Changed content is read as it exists at consumption, and missing resources, unavailable providers, or failed reads surface as errors. Persisting a file reference preserves its address, not the bytes it once identified. Use immutable content storage when a business operation needs to preserve a particular version.
108
-
109
- ## End asynchronous work
110
-
111
- Bind shared services to the plugin lifetime and object-owned instances to the resource lifetime. Register cleanup when creating the owned work.
112
-
113
- Cancellation requests that work stop. Wait for actual completion before releasing what that work still uses.
114
-
115
- Timeline-dependent operations need the host's activity tracking so history changes and object removal can respect active work.
116
-
117
- ## Evolve stored data
118
-
119
- Persistent file formats need explicit preparation when they change. Keep that preparation independent of ordinary service startup.
120
-
121
- Historical records retain their original payloads. Supporting an older shape through decoding is different from rewriting the original historical fact.
122
-
123
- A codec can accept old and current payload shapes while encoding new writes in the current shape:
124
-
125
- ```ts
126
- const current = z.strictObject({ text: z.string() });
127
- const textSchema = z.codec(z.union([z.string(), current]), current, {
128
- decode: value => typeof value === "string" ? { text: value } : value,
129
- encode: value => value,
130
- });
131
- ```
132
-
133
- This schema reads an old string as a current object. Plugin code writes the object; historical reads leave the original string untouched.
61
+ Prepare changes to persistent file formats independently of ordinary service startup. Historical compatibility, current-state migration, and live service initialization have different failure consequences and should remain understandable separately.
@@ -1,39 +1,31 @@
1
1
  # Prepare for plugin development
2
2
 
3
- A plugin adds resources, tools, views, settings pages, Home entries, or services through Asterism's public software development kit (SDK). Development includes preparing a compatible package, verifying its capabilities and lifecycle in the application, and checking the packaged result before sharing it.
3
+ Plugin development starts with a capability users need, not a complete framework of extension points. Build one useful path through the application, then add other contributions when that path requires them.
4
4
 
5
- ## Prepare a project
5
+ ## Target a real application
6
6
 
7
- Use a TypeScript package and the public SDK compatible with the application you intend to run. A package declaration identifies the plugin and its backend, frontend, and optional storage entries.
7
+ Choose the application release your plugin supports and develop against compatible public packages. Development declarations help the editor and type checker; they do not upgrade the APIs supplied by a running application.
8
8
 
9
- Set the plugin's release version in `package.json.version`. That version identifies distributed releases and updates; it does not affect loading or execution. The runtime definition declares its namespace and behavior. Keep ordinary runtime libraries in `dependencies`; npm or another package manager installs them using its usual dependency and lockfile rules.
9
+ Host-provided public packages are shared boundaries, not private libraries to bundle into a plugin. Use development dependencies for authoring and peer dependencies to express that relationship. Ordinary runtime libraries remain the plugin's dependencies.
10
10
 
11
- Declare host-provided packages such as `@asterism-app/sdk` in `peerDependencies` with `"*"`. The running plugin always uses the host's instance, so a narrower range adds maintenance without changing behavior. Install a version of the SDK compatible with the target application in `devDependencies` for editor support and type checking. Extensions to built-in features can use the same arrangement for `@asterism-app/builtin-api`.
11
+ Preserve imports of original shared contracts. A copied declaration can look identical in TypeScript while no longer identifying the same operation at runtime.
12
12
 
13
- npm distribution tags follow the application's release channels: `latest` matches the newest stable application and `next` matches the newest preview application. Install the tag for the application you target, for example `npm install --save-dev --save-exact @asterism-app/sdk@latest`; add `@asterism-app/builtin-api` with the same tag when using built-in domain APIs. Saving an exact version keeps the declarations stable until an intentional update. The packages include TypeScript source, guides, and examples. Installing a newer package does not update the APIs provided by the running application.
13
+ ## Build a narrow vertical slice
14
14
 
15
- Asterism binds shared public imports to the active host or plugin provider. Dependency ranges do not reject loading; missing modules, missing exports, invalid contributions, and initialization errors produce loading failures. Check the APIs your plugin actually uses with TypeScript and exercise them in the target application.
15
+ Start with the plugin's business state, the operation that changes or reads it, and the smallest presentation needed to use it. Keep shared declarations independent of backend and frontend implementations. This makes the boundary visible without exposing implementation details as public API.
16
16
 
17
- The `asterism` field declares a namespaced `id` and the needed `runtime`, `renderer`, and `storage` entry paths, relative to the package root. Runtime and renderer entries default-export their SDK plugin definitions. The runtime namespace must match the manifest ID. The required `displayName` is the plugin's name wherever the application shows it, including plugin management, settings attribution, and session entries; use a message reference owned by the plugin to localize it. The host reads it from the package without running plugin code, so disabled and failed plugins keep their names.
17
+ Choose a stable plugin identity before sharing the package. Treat its display name and release version as product information, distinct from the contracts and namespace that identify its behavior.
18
18
 
19
- Keep shared declarations separate from executable backend and frontend code. Backend work can use local system capabilities; frontend code works through the host's view and communication facilities.
19
+ Avoid scaffolding unused services, views, and persistence. A small working capability makes ownership and cleanup easier to verify; an empty abstraction says little about whether the plugin works.
20
20
 
21
- The `.test.` filename marker is reserved for tests, such as `count.test.ts` or `card.test.tsx`. Tests can remain alongside implementation files. Automatic shared-module discovery and application/package distribution exclude `*.test.*`; runtime entries and their imports contain application code only. Plugin compilation reports explicit imports of test files or Vitest instead of silently removing dependencies.
21
+ ## Validate distinct boundaries
22
22
 
23
- Start with one capability that demonstrates the plugin's purpose. Add further parts when that capability needs them rather than creating an empty framework in advance.
23
+ Type checking establishes agreement with the declarations. Loading and exercising the plugin in the target application establishes whether its contributions and dependencies work together. Neither replaces the other.
24
24
 
25
- ## Load and verify
25
+ Check the normal path, meaningful invalid input, visible failures, and cleanup when the owning resource or plugin ends. Reopen saved work to distinguish durable state from accidental reliance on a live instance.
26
26
 
27
- Prepare the package and its dependencies, run its type checks, then add its local package directory in Asterism's plugin settings. Restart to load changes.
27
+ ## Verify what users receive
28
28
 
29
- The host compiles TypeScript, TSX, and imported CSS at startup. A separate JavaScript build is optional. Generate CSS with the plugin's own toolchain first when using Tailwind, Sass, or another preprocessor. Source changes take effect after restart.
29
+ Test the distributed package in an installed application, not only the source checkout. Include the entries, generated assets, and dependencies that the plugin actually uses. Files available only on the author's machine should not be necessary.
30
30
 
31
- Check the reported loading state and exercise the capability. Verify its normal result, meaningful errors, and cleanup when an object disappears or the application closes.
32
-
33
- Type checking establishes interface consistency. Actual loading and use establish whether the package works in the intended host.
34
-
35
- ## Prepare for sharing
36
-
37
- Include the entries, assets, and dependencies the package needs. Preserve imports of shared public contracts so the host and consumers use the same declarations.
38
-
39
- Test the resulting package in an installed application. Development files available on the author's machine should not be necessary to use the distributed plugin.
31
+ Update public package versions intentionally and repeat the relevant integration checks. A compatible editor view is useful evidence, but the application remains the provider of runtime capabilities.
package/docs/manual.md CHANGED
@@ -1,38 +1,23 @@
1
- # Expose plugin documentation
1
+ # Publish useful plugin documentation
2
2
 
3
- A plugin can make its documentation and examples available through Asterism's Manual resource. The manual exposes the declared directories directly. The same files remain usable in an editor or another development environment.
3
+ A plugin can expose documentation and source examples through Asterism's Manual resource. This makes authoring material available on demand while keeping the same files usable outside the application.
4
4
 
5
- ## Declare directories
5
+ ## Choose what to publish
6
6
 
7
- Add a `manual` array to the plugin's existing `asterism` manifest:
7
+ Expose directories intended for users learning the software or authors developing an integration. Include that material in the distributed package. Internal fixtures, private working notes, and credentials have different audiences and belong outside the published material.
8
8
 
9
- ```json
10
- {
11
- "asterism": {
12
- "id": "example.bridge",
13
- "manual": ["docs", "examples"]
14
- }
15
- }
16
- ```
9
+ Keep documentation with the domain that owns its meaning. Generic hosting concepts belong to the SDK; a plugin's behavior and extension rationale belong to that plugin or its public API package. A separate public API library can own its authoring material without becoming another executable plugin.
17
10
 
18
- Each entry names an existing package-relative subdirectory using `/` separators. Entries must be normalized, must not overlap, and must resolve inside the package. Include those directories in the package's distributed files. A documentation declaration does not require a runtime entry.
11
+ ## Explain decisions that declarations cannot
19
12
 
20
- Declare only directories intended for readers. Source examples can be exposed alongside prose; internal test fixtures and credentials belong outside the declared directories.
13
+ Use prose for mental models, responsibility boundaries, integration choices, and reasons to prefer one composition over another. Public types express concrete interfaces; maintained source examples demonstrate concrete assembly. Repeating either as a field list creates a second, weaker definition.
21
14
 
22
- A public API library named in the plugin's `asterism.publicPackages` can declare its own `asterism.manual` directories. The library needs no plugin identity or executable entry for this declaration. Its documentation remains inside its own package and is available while its implementation provider is loaded.
15
+ An example is worth discussing when the explanation helps an author adapt it. Explain why a service is shared, why a record is durable, or why a view does not own a task. Let the example's source carry its exact syntax.
23
16
 
24
- ## Read through the manual
17
+ Write each article with enough context to stand alone. Organize it around an author or user question, not a tour of every available method. A reading sequence should not be necessary to understand a capability's purpose.
25
18
 
26
- When the plugin loads successfully, its directories appear under `plugins/<plugin-id>/`. For this example, an article at `docs/usage.md` appears as `plugins/example.bridge/docs/usage.md`. The manual supports directory listing, file discovery, content search, and reading selected lines.
19
+ ## Keep runtime guidance with tools
27
20
 
28
- Public-library directories appear under `plugins/<plugin-id>/public/<package-name>/`. The host exposes the same source catalog through the SDK for plugins that provide another documentation interface.
21
+ Models consult the manual when helping with software use or plugin development. Ordinary tool use should not depend on reading it.
29
22
 
30
- The manual reads current files at their original locations. It creates no copied document tree or index. Source declarations follow the loaded package set: changes to declarations, enabling, disabling, or removing a plugin take effect after restart. Plugins with package, startup, or storage failures do not contribute documents.
31
-
32
- A search at a virtual parent covers the directories below it. Globs apply within each selected physical search directory. Results include the complete virtual path, so identical filenames in different plugins remain distinguishable. Reading a file or following an explicitly selected symbolic link remains within the declared directory.
33
-
34
- ## Write independent articles
35
-
36
- Each article should explain its purpose, relevant concepts, prerequisites, and working method without depending on a reading sequence. Keep the context needed to understand the topic in the article itself. Use examples to clarify operations and leave complete interface definitions to the public types.
37
-
38
- Maintain documentation with the domain that owns its meaning. Generic host capabilities belong to the SDK; a plugin's resource behavior and domain extensions belong to that plugin or its public API package. Documentation is reference material and does not become a system instruction merely by appearing in the manual.
23
+ A tool's descriptions, guidelines, and schemas own its complete invocation contract: purpose, input meaning, result interpretation, and execution boundaries. When a runtime misunderstanding appears, improve that contract rather than adding a manual recipe. Documentation can explain how an author designs such a contract without becoming a second place to maintain it.
package/docs/messaging.md CHANGED
@@ -1,21 +1,31 @@
1
- # Provide and consume messaging
1
+ # Compose external messaging
2
2
 
3
- Messaging connects plugins to external conversation services through configured identities. A provider contribution declares its display name, settings, and asynchronous instance factory. Return it in a module's `messagingProviders` contribution. The host creates an instance for each enabled connection, supplies resolved settings and a connection identity, and manages receiving work.
3
+ External messaging separates a platform connection from the workflows that use it. The provider owns platform communication; consumers decide what incoming information means for their resources and users.
4
4
 
5
- Settings use the shared provider setting kinds: text, choice, and secret. Secret values are supplied to the backend factory and remain absent from configuration snapshots. Required values are always present in the resolved settings, choices hold a declared option, and unset optional values are absent. A provider type may have several independently configured connections. The plugin owns any platform-specific state or persistent data used by those connections; declare `forget` to release a removed connection's data, which the host calls after that connection's receiver has ended.
5
+ ## Share transport, not workflow state
6
6
 
7
- An instance supplies its external identity, an ongoing receive operation, conversation listing, message reading, and sending. Receive accepts a cancellation signal and connection-state callbacks, and publishes typed conversation-discovered and messages-received events. A messages-received event contains an ordered, nonempty batch from one conversation; a single message uses a one-element batch. Call `ready` once the platform has accepted the receiver; the connection then reports connected and its retry backoff resets. A transport that restores its own protocol session calls `reconnecting(error)` during the interruption and `ready()` after recovery, preserving its active receiver. Queries and sends have their own signals. A send carries ordered text and file-reference parts plus an optional reply target. Platforms with a caption field combine the text and deliver the files in order. Resolve each reference with `plugin.files` before contacting the platform, so an unreadable source fails as invalid input without sending anything.
7
+ Treat a configured connection as a shared service rather than creating a receiver for every card or session. Platform authentication, protocol recovery, and provider-specific persistence belong with the provider. Each consumer owns its subscriptions and releases them with its own lifetime.
8
8
 
9
- Received messages also have ordered text and file parts. File parts identify a platform attachment and describe its MIME type, filename, and known size. An instance's optional `openFile` operation streams the bytes selected by conversation, message, and file IDs. Verify that the selected file belongs to that address, refresh temporary platform URLs as needed, and preserve cancellation and download errors. Resource consumers create FileRefs with their own source identity; provider messages do not depend on a particular card or session.
9
+ Keep conversation, message, and attachment identities tied to the platform. Several messages arriving together may be related without becoming one message. Preserving individual identity makes later replies, reads, and attachment access unambiguous.
10
10
 
11
- Keep each platform message's own identity and body. Messages sent together may share a `groupId`; providers can deliver them in one batch while keeping reads, replies, and attachments addressable by their individual message IDs. A read selects either recent messages and cursor continuation or a `messageIds` array. ID queries return found messages in requested order, once per resolved message, and identify unavailable requested IDs in `missingIds`, without returning a cursor. Both query forms respect the conversation and optional topic.
11
+ A consumer's read position should not silently become a shared global position. Independent consumers may need different views of the same conversation; query continuation and business decisions about what has been handled are separate concerns.
12
12
 
13
- The host retries failed creation and receive calls. Throw `MessagingError` with `request_failed` for transient conditions such as network failures, rate limits, and server errors, and set `retryAfterMs` when the platform reports a delay. Errors other than `MessagingError` are also treated as transient. Use `unavailable` for conditions that retrying cannot fix, such as rejected credentials or a conflicting receiver; the connection then stays failed until the user changes its configuration or reconnects. Reject unsupported operations explicitly with `unsupported`.
13
+ ## Make platform differences explicit
14
14
 
15
- Use opaque strings for platform conversation, topic, and message identities. Give every sender a role relative to the connection: `self` for the connection's own identity, `participant` for another party, and `system` for content the platform produced rather than a party authored. Cursors are opaque, reusable query positions scoped by the provider. A query may compare changes with an earlier cursor, but it must not advance a shared read position. Cursor rejection should explain that the supplied position cannot be used.
15
+ Translate platform behavior without pretending that every service has identical capabilities. Reject unsupported operations explicitly. Distinguish recoverable transport interruptions from conditions requiring user action, so recovery belongs to the layer that can actually perform it.
16
16
 
17
- Consumers access `plugin.messaging`. List connection identities, resolve a specific connection to an operation handle, and subscribe to external events and connection changes. Resolve at the consumer's request boundary when configuration must remain fixed across its operations. Each handle retains its captured instance; operations wait for a connection attempt in progress and fail with the attempt's error otherwise. Current external content remains current at handling time.
17
+ Attachments need the same care as text. An address to a platform file is not a permanently available download URL. Resolve it through the provider that understands its identity, and preserve cancellation and download failures.
18
18
 
19
- Provider instances are shared across consumers. A plugin should not create a second receiver for each card or session. Its consumers own their subscriptions and release them with their lifetimes. A listener failure is logged and does not affect other listeners or the provider. Connection removal or provider unavailability prevents new resolutions; provider shutdown cancels its outstanding work.
19
+ When sending has external effects, resolve required input before beginning delivery. If a platform turns one logical submission into several sends, expose failures honestly rather than implying that partial delivery was atomic.
20
20
 
21
- The service has no Agent semantics. A consumer chooses whether an external event updates a view, records a fact, or submits input through a paradigm's public API. Builtin resources use links to select recipients and expose tools. Other plugins may compose the same service differently.
21
+ ## Choose when configuration is captured
22
+
23
+ Resolve a connection at the consumer's request boundary when related operations should use one configuration. Read current external content when handling the operation. Configuration identity and mutable conversation content need not have the same lifetime.
24
+
25
+ Cancellation belongs to the work it controls. Cancelling one consumer's query should not end a receiver shared with other consumers. Conversely, ending the provider must release the work it owns.
26
+
27
+ ## Translate events deliberately
28
+
29
+ A messaging event is not inherently an Agent message. A consumer may update a view, record a durable fact, or submit input through a paradigm's public API. The integration owns that choice and the readable explanation of the event.
30
+
31
+ For example, an issue-tracker bridge can share one platform receiver across sessions while each resource chooses its recipients and records its own processing decisions. The provider understands the platform; the bridge understands the work.
@@ -1,35 +1,27 @@
1
- # Build a small plugin
1
+ # Adapt a small plugin
2
2
 
3
- A counter plugin demonstrates the complete path from shared declarations to backend behavior and a resource card. The SDK includes it as an ordinary package directory under `examples/counter`, with source files, a package manifest, and a TypeScript configuration. Its code is the maintained example; this guide explains how to use and adapt it.
3
+ The SDK's counter package in `examples/counter` is a complete plugin, not a specification for every plugin's structure. Its maintained source shows concrete assembly. Use it to understand ownership and then change the design to fit the capability you need.
4
4
 
5
- ## Prepare the package
5
+ ## Follow one change through the system
6
6
 
7
- Copy the counter directory to a writable development location. Its development dependency selects the SDK version used by the example. Use an Asterism application that provides those APIs. The SDK peer dependency describes a host-provided package, and the host does not use its version range to gate loading. React, React Intl, and Zod are also shared public dependencies supplied by the host when the plugin runs.
7
+ The counter separates a shared declaration, backend work, and a card that presents the result. Backend and frontend import the same contracts; sharing a name or copying a schema would not create the same runtime identity.
8
8
 
9
- Run `npm install` and `npm run typecheck` in the copied directory. The host compiles the TypeScript, TSX, and imported CSS entries, so a separate JavaScript build is optional. Add the package directory in Asterism's plugin settings and restart the application to load it.
9
+ An increment updates the current value and records the change together. That is a deliberate product choice: current data supports use now, while the record explains what happened. The counter does not promise that browsing history restores its value. A different resource may need a different relationship between current state and history.
10
10
 
11
- ## Follow the data
11
+ The card initiates work without becoming its durable owner. This separation matters when a view closes, remounts, or fails while the resource remains present. UI pending state belongs to the interaction; committed results belong to the backend.
12
12
 
13
- Shared declarations identify the counter, its private current value, projected view, change record, creation entry, increment action, read tool, settings, and typed call. Backend and frontend code import the same declarations. Copying a declaration under the same name does not establish shared runtime identity.
13
+ The model-facing read operation exposes an existing capability rather than inventing a second source of truth. Its registration does not itself grant access to the counter. Treat visibility, authorization, and presentation as separate choices.
14
14
 
15
- Creation establishes the object. Incrementing reads the configured step, saves the current value, and appends a historical change in one synchronous commit. The example keeps the latest counter value when browsing history; it does not implement restoration. Network and file work belongs outside synchronous commits.
15
+ ## Adapt ownership before adding features
16
16
 
17
- The card reads projected data and invokes the public increment action. Each button owns its pending state and displays failures. Actions return receipts that the view checks; typed calls and settings saves reject on failure. A settings page edits the step and reads it back through the backend call.
17
+ Choose a distinct plugin identity for a new package. Keep shared contracts independent of executable implementations, but group a capability's code so its state transitions remain understandable together.
18
18
 
19
- The example also contributes a Home entry. It prepares a counter, then initializes a session containing it in one transaction. This entry works with the builtin paradigm disabled and requires no conversation input.
19
+ Decide whether each new piece of state is a current value, a historical fact, a preference, or temporary interaction state. Decide who ends any new asynchronous work. A connection shared by all counters would belong to the plugin; a process meaningful only for one counter would belong to that resource.
20
20
 
21
- The model tool reads the same counter value through its resource implementation. Registering the tool does not grant access: an agent needs a link to the counter, and the operation must be available in its execution environment.
21
+ A Home entry can start a session around the counter without introducing an Agent or a first message. Keep that independence when adapting the example unless conversation is part of the new plugin's domain.
22
22
 
23
- ## Adapt the package
23
+ ## Check the adapted design
24
24
 
25
- Choose a distinct plugin identity before using the example as a new plugin. Keep shared declarations independent of backend and frontend implementations. Add resource behavior through actions and expose an operation as a model tool when the model needs to call it.
25
+ Use a compatible application and public SDK for development. Type checking checks contract agreement; loading the package and exercising it checks the integration.
26
26
 
27
- Imported CSS Modules keep the counter's class names local. Host theme variables provide colors. The storage entry declares the managed configuration format; add consecutive migrations when that format changes. Credentials belong in the secret service, and retained file content uses the content service.
28
-
29
- Object-owned external connections belong to the resource's attachment lifetime. Register their cleanup when opening them. Shared services belong to the plugin lifetime. Managed tasks own asynchronous work and pass cancellation to their I/O.
30
-
31
- ## Verify the result
32
-
33
- Open the plugin settings page, change the step, and read it back. Create a counter, increment it, and verify the card and history. Link the counter to an agent and use its read tool.
34
-
35
- After edits, run type checking and restart Asterism. Verify invalid input, failure messages, cleanup, and reopening saved objects. Type checking establishes interface consistency; loading and using the package establishes its behavior in the host.
27
+ Trace one change from the initiating interface to saved state and history. Then check invalid input, visible failure, reopening saved objects, and cleanup. These checks should test promises your resource makes, not merely confirm that the copied example still has the same controls.
@@ -1,33 +1,29 @@
1
1
  # Organize a plugin
2
2
 
3
- A plugin is the unit of installation, identity, settings, and lifetime. Its internal modules group capabilities that share that ownership.
3
+ A plugin is a unit of installation, identity, settings, and lifetime. Internal modules group capabilities that share that ownership; they need not become separate public abstractions.
4
4
 
5
- ## Separate responsibilities
5
+ ## Separate responsibilities, keep capabilities cohesive
6
6
 
7
- Shared contracts describe transferable data and operations. Backend implementations perform work. Frontend views present state and collect input.
7
+ Shared contracts describe transferable data and operations. Backend implementations own work and persistence. Frontend views present state and collect input. Keep shared declarations independent of libraries that belong only to one implementation environment.
8
8
 
9
- Keep shared declarations independent of backend-only or frontend-only libraries. A view reaches its backend through typed communication rather than importing the backend implementation.
9
+ A view reaches backend behavior through typed communication rather than importing its implementation. Within that boundary, keep a capability's declarations, behavior, and presentation understandable together. Compose capabilities through explicit dependencies instead of exposing internal layers merely because they exist.
10
10
 
11
- Group a capability's declarations, implementation, and presentation so they remain understandable together. Compose capabilities at the plugin entry through explicit dependencies.
11
+ ## Choose a domain boundary
12
12
 
13
- ## Use public extension points
13
+ Use a domain's public extension points when adding to its existing behavior. A plugin with its own resource can instead own that resource's behavior and presentation. Extending an Agent and implementing a new paradigm are different commitments.
14
14
 
15
- The general SDK supplies host services and contribution interfaces. Built-in domain APIs expose extensions specific to existing features, such as Agent interaction.
15
+ A paradigm may define how work starts, how requests are assembled, and how execution is presented. Sessions and host capabilities do not require a conversation card. Choose the composition that fits the workflow rather than treating the bundled paradigm as the host's mandatory object model.
16
16
 
17
- Use a domain extension when adding to that feature. A plugin with its own resource can define its own behavior and presentation.
17
+ ## Publish only what consumers need
18
18
 
19
- A paradigm plugin can own a Home entry, configuration, request assembly, and execution behavior. The host supplies sessions, concrete model access, interactive terminals, command execution, MCP, provider usage, and raw skill and instruction catalogs. Compose these capabilities according to the workflow; an Agent resource or conversation card is optional.
19
+ A public package is useful when multiple plugins need the same declarations or service boundary. Publish capabilities with an intentional meaning for consumers, not a mirror of the provider's internal organization.
20
20
 
21
- ## Share contracts and services
21
+ For a small extension, public exports from the implementation package may be sufficient. A separate API library can make sense when the shared domain has its own authoring surface and should remain independent of implementation imports. Neither choice makes the library a second plugin or gives consumers access to private state.
22
22
 
23
- A public package can expose declarations or services for other plugins. Consumers declare ordinary package dependencies in `package.json` and import the original public values. The host derives initialization and cleanup dependencies from those imports, including imports through intermediate packages.
23
+ Import original public values. Shared contracts carry runtime identity as well as types, so a local copy is not a substitute for the provider's declaration. Development package versions support authoring; the enabled provider supplies the running implementation.
24
24
 
25
- Expose shared values through `./public` in the package's standard exports. Public imports bind to the enabled provider's actual exports, including imports through intermediate npm packages. The host uses the import graph for initialization order and reports missing exports or unavailable providers. Package versions and dependency ranges remain package-management metadata; local development copies do not replace the active provider.
25
+ ## Keep service ownership with the provider
26
26
 
27
- For a separate API library, declare its package name in the implementation plugin's `asterism.publicPackages` array. Install that library as an ordinary dependency and declare its public entry points through standard package exports. Consumers resolve those entries from the enabled provider's installation. Package names cannot be claimed by competing enabled providers across these two declaration forms.
27
+ A provider owns shared initialization and cleanup. Consumers depend on the capability they use and release their own subscriptions or requests without ending services shared by others.
28
28
 
29
- Libraries that depend on native binaries or files relative to their installed module can be listed in `asterism.runtimeExternals`. The host preserves their resolved installed locations instead of relocating their code into the plugin cache.
30
-
31
- A shared declaration has runtime identity as well as a name. Copying it under the same name does not establish shared identity. Backend and frontend environments are separate even when they use the same contract.
32
-
33
- Shared service initialization and cleanup belong to the provider. A consumer should depend on the capability it needs rather than the provider's internal organization.
29
+ Keep that ownership explicit when composing modules. A dependency should explain why a capability is needed, not require consumers to understand the provider's file layout or startup internals.
@@ -1,75 +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
- Provide `disposalWarnings()` when the resource backend owns live instances whose termination needs confirmation. Enumerate only those live instances, returning their resource references and warning messages. The host selects the affected resources for removal, archival, or application exit and supplies their current titles. Saved resource data alone does not need an exit warning; do not restore instances to check them. Warning discovery does not perform cleanup, which remains owned by lifetimes.
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
- Creation supplies initial state. Actions change the object through typed application or plugin operations. Views present the resulting state.
13
+ ## Design information and access separately
14
14
 
15
- 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.
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
- 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.
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
- 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.
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
- 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.
21
+ ## Choose a callable boundary
22
22
 
23
- 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.
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
- ## Add a model operation
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
- 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.
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
- 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.
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
- 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.
31
+ ## Put invocation knowledge in the contract
32
32
 
33
- 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.
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
- 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.
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
- 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.
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
- 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.
39
+ ## Compose model execution deliberately
40
40
 
41
- 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.
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
- 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.
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
- 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.
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
- 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.
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
- 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.
49
+ ## Separate services from their interfaces
50
50
 
51
- 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.
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
- 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.
54
-
55
- 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.
56
-
57
- 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.
58
-
59
- 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.
60
-
61
- ## Connect other interactions
62
-
63
- Typed calls connect request and response between services or views. Events announce transient changes. Object channels support sustained data such as an interactive screen.
64
-
65
- An action or service call is not automatically a model tool. Expose it deliberately when the model needs that operation.
66
-
67
- ## Use shell capabilities
68
-
69
- 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.
70
-
71
- 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.
72
-
73
- 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.
74
-
75
- 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.2",
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
  }