@asterism-app/sdk 1.10.2 → 1.12.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 +10 -10
- package/docs/data-and-lifecycle.md +29 -101
- package/docs/getting-started.md +15 -23
- package/docs/manual.md +12 -27
- package/docs/messaging.md +21 -11
- package/docs/minimal-plugin.md +14 -22
- package/docs/project-structure.md +14 -18
- package/docs/resources-and-tools.md +27 -49
- package/docs/session-entries.md +15 -17
- package/docs/views-and-settings.md +26 -99
- package/package.json +1 -1
- package/src/content-runtime.ts +1 -1
- package/src/model-catalog.ts +5 -0
- package/src/model-media.ts +0 -2
- package/src/models.ts +8 -2
- package/src/module-contract.ts +6 -0
- package/src/provider-usage.ts +21 -0
- package/src/reference-urls.ts +15 -1
- package/src/renderer-island.ts +2 -0
- package/src/renderer-resource-open.ts +5 -0
package/README.md
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
# Asterism SDK
|
|
2
2
|
|
|
3
|
-
The SDK
|
|
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
|
-
|
|
5
|
+
## Design against a shared boundary
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
11
|
+
## Develop for the target application
|
|
12
12
|
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
17
|
+
## Keep authoring material purposeful
|
|
18
18
|
|
|
19
|
-
The
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
13
|
+
## Treat encoding as a domain boundary
|
|
14
14
|
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
21
|
+
## Decide what a template can reuse
|
|
22
22
|
|
|
23
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
29
|
+
## Commit facts, then observe them
|
|
30
30
|
|
|
31
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
39
|
+
## Read history through its owner
|
|
40
40
|
|
|
41
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
47
|
+
## Choose between an address and preserved bytes
|
|
48
48
|
|
|
49
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
55
|
+
## End work with its owner
|
|
56
56
|
|
|
57
|
-
|
|
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
|
|
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
|
-
|
|
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.
|
package/docs/getting-started.md
CHANGED
|
@@ -1,39 +1,31 @@
|
|
|
1
1
|
# Prepare for plugin development
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
##
|
|
5
|
+
## Target a real application
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
13
|
+
## Build a narrow vertical slice
|
|
14
14
|
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
21
|
+
## Validate distinct boundaries
|
|
22
22
|
|
|
23
|
-
|
|
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
|
-
|
|
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
|
-
|
|
27
|
+
## Verify what users receive
|
|
28
28
|
|
|
29
|
-
|
|
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
|
-
|
|
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
|
-
#
|
|
1
|
+
# Publish useful plugin documentation
|
|
2
2
|
|
|
3
|
-
A plugin can
|
|
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
|
-
##
|
|
5
|
+
## Choose what to publish
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
11
|
+
## Explain decisions that declarations cannot
|
|
19
12
|
|
|
20
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
19
|
+
## Keep runtime guidance with tools
|
|
27
20
|
|
|
28
|
-
|
|
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
|
-
|
|
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
|
-
#
|
|
1
|
+
# Compose external messaging
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
5
|
+
## Share transport, not workflow state
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
13
|
+
## Make platform differences explicit
|
|
14
14
|
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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.
|
package/docs/minimal-plugin.md
CHANGED
|
@@ -1,35 +1,27 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Adapt a small plugin
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
##
|
|
5
|
+
## Follow one change through the system
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
15
|
+
## Adapt ownership before adding features
|
|
16
16
|
|
|
17
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
23
|
+
## Check the adapted design
|
|
24
24
|
|
|
25
|
-
|
|
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
|
-
|
|
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
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
11
|
+
## Choose a domain boundary
|
|
12
12
|
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
|
|
17
|
+
## Publish only what consumers need
|
|
18
18
|
|
|
19
|
-
A
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
25
|
+
## Keep service ownership with the provider
|
|
26
26
|
|
|
27
|
-
|
|
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
|
-
|
|
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
|
-
#
|
|
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.
|
|
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
|
-
##
|
|
5
|
+
## Choose the object boundary
|
|
6
6
|
|
|
7
|
-
Use a resource for something that belongs in a session and can be
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
13
|
+
## Design information and access separately
|
|
14
14
|
|
|
15
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
21
|
+
## Choose a callable boundary
|
|
22
22
|
|
|
23
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
31
|
+
## Put invocation knowledge in the contract
|
|
32
32
|
|
|
33
|
-
Tool
|
|
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
|
|
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
|
-
|
|
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
|
-
|
|
39
|
+
## Compose model execution deliberately
|
|
40
40
|
|
|
41
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
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
|
-
|
|
49
|
+
## Separate services from their interfaces
|
|
50
50
|
|
|
51
|
-
|
|
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
|
-
|
|
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.
|
package/docs/session-entries.md
CHANGED
|
@@ -1,31 +1,29 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Design a session starting point
|
|
2
2
|
|
|
3
|
-
A session contains a history tree and a workbench.
|
|
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
|
|
5
|
+
## Own the starting experience
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
11
|
+
## Separate preparation from commitment
|
|
12
12
|
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
19
|
+
## Keep a submission's identity
|
|
20
20
|
|
|
21
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
#
|
|
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
|
-
|
|
5
|
+
## Match presentation to ownership
|
|
6
6
|
|
|
7
|
-
|
|
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
|
-
|
|
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
|
-
|
|
11
|
+
## Give expanded views a meaningful identity
|
|
12
12
|
|
|
13
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
21
|
+
## Make locations reconstructable
|
|
22
22
|
|
|
23
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
##
|
|
29
|
+
## Keep transfers with the right owner
|
|
30
30
|
|
|
31
|
-
|
|
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
|
-
|
|
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
|
-
|
|
35
|
+
## Separate settings drafts from shared configuration
|
|
36
36
|
|
|
37
|
-
A
|
|
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
|
-
|
|
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
|
-
##
|
|
41
|
+
## Offer commands as focused interactions
|
|
42
42
|
|
|
43
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
49
|
+
## Keep language independent of work
|
|
50
50
|
|
|
51
|
-
|
|
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
package/src/content-runtime.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { ContentRef, ContentRange } from "./content.ts";
|
|
2
2
|
import type { Json } from "./json.ts";
|
|
3
3
|
|
|
4
|
-
/**
|
|
4
|
+
/** Read complete content or a byte range; open streams the selected bytes in chunks. */
|
|
5
5
|
export interface ContentReader {
|
|
6
6
|
read(ref: ContentRef, range?: ContentRange): Promise<Uint8Array>;
|
|
7
7
|
open(ref: ContentRef, range?: ContentRange): AsyncIterable<Uint8Array>;
|
package/src/model-catalog.ts
CHANGED
|
@@ -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/model-media.ts
CHANGED
|
@@ -7,5 +7,3 @@ export function fileMediaType(file: { type: string; name: string }): string {
|
|
|
7
7
|
}
|
|
8
8
|
/** A derived classification for UI display, not a model capability. */
|
|
9
9
|
export const previewsAsImage = (mediaType: string) => mediaType.startsWith("image/");
|
|
10
|
-
/** Client resource limits: per-file size, count, and total size leave room for protocol envelopes and base64. */
|
|
11
|
-
export const modelInputLimits = { file: 5 * 1024 * 1024, files: 20, total: 20 * 1024 * 1024 } as const;
|
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
|
-
|
|
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
|
}
|
package/src/module-contract.ts
CHANGED
|
@@ -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> {
|
package/src/provider-usage.ts
CHANGED
|
@@ -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],
|
package/src/reference-urls.ts
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
|
+
import { parseModelExpression, type ModelExpression } from "./model-selection.ts";
|
|
2
|
+
|
|
1
3
|
/**
|
|
2
4
|
* Reference URLs are plain strings that name something the model or the user can look up: `resource:` addresses a
|
|
3
|
-
* location inside a session resource, `skill:` addresses a skill package through the skill catalog
|
|
5
|
+
* location inside a session resource, `skill:` addresses a skill package through the skill catalog, and `model:`
|
|
6
|
+
* addresses a configured model by its provider/model expression. A reference may
|
|
4
7
|
* name something that does not exist; parsing checks only the format.
|
|
5
8
|
*/
|
|
6
9
|
|
|
@@ -39,6 +42,17 @@ export function parseSkillUrl(value: string): SkillUrl | null {
|
|
|
39
42
|
} catch { return null; }
|
|
40
43
|
}
|
|
41
44
|
|
|
45
|
+
/** `model:<provider>/<model>`: model IDs may contain additional slash-separated segments. */
|
|
46
|
+
export function modelUrl(expression: string): string {
|
|
47
|
+
return `model:${encodePath(expression)}`;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export function parseModelUrl(value: string): ModelExpression | null {
|
|
51
|
+
const match = /^model:([^?#\s]+)$/u.exec(value);
|
|
52
|
+
if (!match) return null;
|
|
53
|
+
try { return parseModelExpression(decodePath(match[1]!)); } catch { return null; }
|
|
54
|
+
}
|
|
55
|
+
|
|
42
56
|
/** The text form of a reference: a Markdown link whose label is display text and whose destination is the URL. */
|
|
43
57
|
export function referenceMarkdown(label: string, url: string): string {
|
|
44
58
|
return `[${label}](${url})`;
|
package/src/renderer-island.ts
CHANGED
|
@@ -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
|
}
|