@asterism-app/sdk 1.10.1 → 1.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- 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 -47
- package/docs/session-entries.md +15 -17
- package/docs/views-and-settings.md +26 -99
- package/package.json +1 -1
- package/src/model-catalog.ts +5 -0
- package/src/models.ts +8 -2
- package/src/module-contract.ts +6 -0
- package/src/provider-usage.ts +21 -0
- package/src/renderer-island.ts +2 -0
- package/src/renderer-resource-open.ts +5 -0
- package/src/runtime-contracts.ts +11 -3
- package/src/runtime-resources.ts +2 -2
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.
|