@arnilo/prism 0.7.0 → 0.8.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/CHANGELOG.md +35 -0
- package/README.md +12 -11
- package/dist/agent-approval.d.ts +4 -0
- package/dist/agent-approval.js +5 -1
- package/dist/agent-run-lifecycle.js +29 -5
- package/dist/agent-run-state.d.ts +13 -1
- package/dist/agent-run-state.js +12 -2
- package/dist/agent-session/helpers.js +6 -1
- package/dist/agent-session/session/assemble.js +126 -5
- package/dist/agent-session/session/persist.d.ts +16 -0
- package/dist/agent-session/session/persist.js +58 -2
- package/dist/agent-session/session/provider-round.d.ts +3 -3
- package/dist/agent-session/session/provider-round.js +12 -6
- package/dist/agent-session/session/tool-round.js +4 -1
- package/dist/agent-session/session/types.d.ts +12 -1
- package/dist/agent-session/session.d.ts +2 -0
- package/dist/agent-session/session.js +2 -0
- package/dist/checkpoints.js +7 -11
- package/dist/contracts-core/content.d.ts +5 -0
- package/dist/contracts-core/loop.d.ts +42 -0
- package/dist/contracts-core/run-limits.d.ts +2 -0
- package/dist/contracts-protocol.d.ts +15 -3
- package/dist/contracts-run-state.d.ts +26 -5
- package/dist/evidence-grounding.d.ts +29 -0
- package/dist/evidence-grounding.js +162 -0
- package/dist/host-composition.d.ts +13 -0
- package/dist/host-composition.js +33 -2
- package/dist/index.d.ts +6 -2
- package/dist/index.js +3 -1
- package/dist/provider-events.d.ts +3 -1
- package/dist/provider-events.js +2 -2
- package/dist/providers/transport.d.ts +3 -1
- package/dist/providers/transport.js +36 -0
- package/dist/redaction.js +18 -2
- package/dist/run-bundle.d.ts +89 -0
- package/dist/run-bundle.js +149 -0
- package/dist/testing/state-concurrency-conformance.js +5 -12
- package/docs/ag-ui.md +5 -0
- package/docs/agent-loops.md +33 -0
- package/docs/agent-session-runtime.md +4 -3
- package/docs/coding-security.md +1 -0
- package/docs/coding-tools.md +0 -1
- package/docs/compaction-observational-memory.md +1 -1
- package/docs/connected-apps.md +116 -0
- package/docs/context-and-skills.md +13 -0
- package/docs/core.md +1 -1
- package/docs/diagrams.md +6 -6
- package/docs/document-reader.md +9 -9
- package/docs/documents.md +32 -11
- package/docs/durable-runs.md +87 -0
- package/docs/enterprise-postgres-state.md +4 -0
- package/docs/execution-timeline.md +6 -0
- package/docs/guardrails.md +33 -0
- package/docs/history/079-messaging-primitive-review.md +391 -0
- package/docs/history/080-messaging-followon-primitive-review.md +234 -0
- package/docs/history/081-connected-apps-primitive-review.md +74 -0
- package/docs/history/083-prism-work-primitive-review.md +84 -0
- package/docs/history/084-primitive-review.md +96 -0
- package/docs/history/085-honesty-and-cut-primitive-review.md +91 -0
- package/docs/history/README.md +5 -0
- package/docs/history/release-handoffs.md +38 -0
- package/docs/host-compositions.md +8 -6
- package/docs/host-security.md +2 -2
- package/docs/index.md +47 -29
- package/docs/live-testing.md +5 -3
- package/docs/mcp-tools.md +1 -0
- package/docs/messaging-channel-operations.md +166 -0
- package/docs/messaging-channels.md +150 -0
- package/docs/migrate-to-0.8.md +124 -0
- package/docs/migration.md +30 -0
- package/docs/model-registry.md +12 -2
- package/docs/openapi-tools.md +1 -1
- package/docs/operations.md +1 -3
- package/docs/options-index.md +34 -2
- package/docs/peer-dependencies.md +6 -6
- package/docs/postgres-persistence.md +1 -1
- package/docs/provider-layer.md +2 -2
- package/docs/provider-packages.md +20 -20
- package/docs/providers/neuralwatt.md +5 -1
- package/docs/rag.md +1 -1
- package/docs/release-and-install.md +52 -46
- package/docs/run-bundle.md +92 -0
- package/docs/runs-and-usage.md +14 -0
- package/docs/server.md +2 -0
- package/docs/sheets.md +9 -9
- package/docs/signal-channel.md +112 -0
- package/docs/speech.md +5 -1
- package/docs/sqlite-persistence.md +1 -1
- package/docs/telegram-channel.md +157 -0
- package/docs/testing.md +2 -2
- package/docs/wiki.md +1 -1
- package/docs/work-artifacts-and-review.md +1 -1
- package/docs/work-connectors.md +9 -9
- package/docs/work-sandbox.md +115 -0
- package/docs/work-tools.md +38 -16
- package/package.json +5 -3
- package/templates/business-worker/manifest.json +2 -1
- package/templates/business-worker/src/agent.ts.tmpl +1 -1
- package/templates/business-worker/src/tests/agent.test.ts.tmpl +1 -1
package/docs/work-tools.md
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
# Work tools
|
|
2
2
|
|
|
3
|
-
Optional `@arnilo/prism-
|
|
3
|
+
Optional `@arnilo/prism-work/connectors` subpath: identity-scoped Microsoft 365 and Google Workspace connectors. Host-pinned CLI binaries or pinned HTTP adapters; hard-coded operation maps; draft-then-approve mutations; side-effect idempotency; shared mail/calendar/file/task result shapes. HTTP file gets persist untrusted bytes to a host artifact store or contained filesystem, never the transcript.
|
|
4
4
|
|
|
5
5
|
## When to use
|
|
6
6
|
|
|
7
|
-
Use when agents must read or mutate tenant mail/calendar/files/tasks through
|
|
7
|
+
Use when agents must read or mutate tenant mail/calendar/files/tasks through a host-pinned enterprise CLI or a pinned HTTP adapter — not through model-built shell strings, model-supplied URLs, or generic Graph/Discovery free-form calls.
|
|
8
8
|
|
|
9
9
|
## Install
|
|
10
10
|
|
|
11
11
|
```bash
|
|
12
|
-
npm install @arnilo/prism-
|
|
12
|
+
npm install @arnilo/prism @arnilo/prism-work
|
|
13
13
|
# host separately:
|
|
14
14
|
# npm i -g @pnp/cli-microsoft365
|
|
15
15
|
# npm i -g @googleworkspace/cli
|
|
@@ -20,26 +20,28 @@ npm install @arnilo/prism-core
|
|
|
20
20
|
```ts
|
|
21
21
|
import {
|
|
22
22
|
createWorkTools,
|
|
23
|
-
|
|
23
|
+
createMicrosoft365HttpAdapter,
|
|
24
24
|
createGoogleWorkspaceCliAdapter,
|
|
25
|
+
createGoogleWorkspaceHttpAdapter,
|
|
25
26
|
createMemoryIdempotencyStore,
|
|
26
|
-
} from "@arnilo/prism-
|
|
27
|
-
|
|
27
|
+
} from "@arnilo/prism-work/connectors";
|
|
28
|
+
import { createOAuthWorkTokenProvider } from "@arnilo/prism-core/credentials/node";
|
|
29
|
+
// or: import { createGoogleWorkspaceCliAdapter } from "@arnilo/prism-work/connectors/google-workspace";
|
|
28
30
|
|
|
29
|
-
const microsoft365 =
|
|
30
|
-
binary: process.env.M365_BIN!,
|
|
31
|
-
configDir: `/var/prism/m365/${tenant}/${user}`,
|
|
31
|
+
const microsoft365 = createMicrosoft365HttpAdapter({
|
|
32
32
|
identity,
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
tokenProvider: createOAuthWorkTokenProvider({ provider: m365OAuth, store, envVar: "M365_ACCESSTOKEN" }),
|
|
34
|
+
accessEnvVar: "M365_ACCESSTOKEN",
|
|
35
35
|
});
|
|
36
|
+
// Or retain createMicrosoft365CliAdapter({ binary, configDir, identity }) for host-pinned m365.
|
|
36
37
|
|
|
37
|
-
const googleWorkspace =
|
|
38
|
-
binary: process.env.GWS_BIN!,
|
|
39
|
-
configDir: `/var/prism/gws/${tenant}/${user}`,
|
|
38
|
+
const googleWorkspace = createGoogleWorkspaceHttpAdapter({
|
|
40
39
|
identity,
|
|
40
|
+
tokenProvider: createOAuthWorkTokenProvider({ provider: gwsOAuth, store, envVar: "GOOGLE_ACCESS_TOKEN" }),
|
|
41
|
+
accessEnvVar: "GOOGLE_ACCESS_TOKEN",
|
|
41
42
|
// allowedOps: add docs.create / sheets.create / slides.create when gated
|
|
42
43
|
});
|
|
44
|
+
// Or retain createGoogleWorkspaceCliAdapter({ binary, configDir, identity }) for host-pinned gws.
|
|
43
45
|
|
|
44
46
|
const tools = createWorkTools({
|
|
45
47
|
microsoft365,
|
|
@@ -47,6 +49,9 @@ const tools = createWorkTools({
|
|
|
47
49
|
idempotencyStore: createMemoryIdempotencyStore(),
|
|
48
50
|
approval: { isApproved: ({ draftId }) => hostHasApproved(draftId) },
|
|
49
51
|
externalRecipients: { allow: (addr) => addr.endsWith("@contoso.com") },
|
|
52
|
+
scanAttachment: ({ bytes }) => hostScan(bytes), // required before file-get persistence
|
|
53
|
+
artifacts: hostWorkArtifacts, // creates ArtifactBodyRef values and owns body storage
|
|
54
|
+
filesystem: containedFilesystem, // optional destination/source for work-sandbox files
|
|
50
55
|
});
|
|
51
56
|
```
|
|
52
57
|
|
|
@@ -64,7 +69,9 @@ Verified against [CLI for Microsoft 365](https://pnp.github.io/cli-microsoft365/
|
|
|
64
69
|
| `calendar.list` | `m365 outlook event list --output json` |
|
|
65
70
|
| `calendar.add` | `m365 outlook event add --output json --subject … --start … --end …` |
|
|
66
71
|
| `file.list` | `m365 file list --output json --webUrl … --folderUrl …` |
|
|
72
|
+
| `file.get` | HTTP only: `GET /me/drive/items/{id}/content` on `graph.microsoft.com` |
|
|
67
73
|
| `file.add` | `m365 file add --output json --folderUrl … --filePath …` |
|
|
74
|
+
| `file.copy` | `m365 file copy --output json --webUrl … --sourceUrl … --targetUrl …` (draft-then-approve) |
|
|
68
75
|
| `file.share` | `m365 spo file sharinglink add` (`--scope organization` only) |
|
|
69
76
|
| `todo.*` / `planner.*` | capability-gated via `allowedOps` |
|
|
70
77
|
|
|
@@ -80,12 +87,22 @@ Verified against [`@googleworkspace/cli` / `gws`](https://github.com/googleworks
|
|
|
80
87
|
| `calendar.list` | `gws calendar events list --params … --fields …` |
|
|
81
88
|
| `calendar.add` | `gws calendar events insert --params … --json …` |
|
|
82
89
|
| `file.list` | `gws drive files list --params … [--page-all]` (NDJSON when paginated) |
|
|
90
|
+
| `file.get` | HTTP only: `GET /drive/v3/files/{id}?alt=media` on `www.googleapis.com` |
|
|
83
91
|
| `file.add` | `gws drive files create --json … --upload …` |
|
|
84
92
|
| `file.share` | `gws drive permissions create` (`type=domain\|user` only; `anyone` denied) |
|
|
85
93
|
| `task.*` | `gws tasks tasks list\|insert\|patch` |
|
|
86
94
|
| `docs.create` / `sheets.create` / `slides.create` | capability-gated via `allowedOps` |
|
|
95
|
+
| `docs.update` / `sheets.update` / `slides.update` | capability-gated fixed-shape updates; never free-form batch requests |
|
|
87
96
|
|
|
88
|
-
|
|
97
|
+
### Microsoft 365 HTTP adapter
|
|
98
|
+
|
|
99
|
+
`createMicrosoft365HttpAdapter()` uses host-provided OAuth tokens only in the `Authorization` header and pinned fetch against `graph.microsoft.com`. Its fixed map covers Outlook messages/events, draft-then-approve OneDrive copy/sharing, and capability-gated To Do/Planner tasks. `ensureReady()` performs a bounded Graph `/me` request. `m365_file_get` accepts only an item ID and uses fixed `/me/drive/items/{id}/content`; it writes untrusted bytes to an artifact and/or contained filesystem after `scanAttachment`, returning only `{ artifact?, path?, byteLength, contentHash, untrusted: true }`. File list/upload/copy accepts an HTTPS Graph Drive-item URL; arbitrary SharePoint links are rejected rather than resolved with an extra request. The CLI adapter remains available for CLI-specific SharePoint paths.
|
|
100
|
+
|
|
101
|
+
### Google Workspace HTTP adapter
|
|
102
|
+
|
|
103
|
+
`createGoogleWorkspaceHttpAdapter()` uses host-provided OAuth tokens only in the `Authorization` header and pinned fetch against `docs.googleapis.com`, `gmail.googleapis.com`, `sheets.googleapis.com`, `slides.googleapis.com`, `www.googleapis.com`, and `tasks.googleapis.com`. Its operation map is fixed: Gmail messages, Calendar events, Drive files/permissions, Google Tasks, and capability-gated native Docs/Sheets/Slides creates plus draft-then-approve fixed-shape updates. Docs accepts only replace-text and insert-text requests; Sheets PUTs a string matrix with `valueInputOption=RAW`; Slides accepts only shape text insertion. No tool accepts a free-form `requests[]`. `ensureReady()` performs a bounded Gmail profile request; `gws_file_get` accepts only an item ID and uses fixed `Drive files.get?alt=media`, persisting untrusted bytes exactly like `m365_file_get`. `file.add` accepts a host-local path, `ArtifactBodyRef`, or contained sandbox path; its approved draft binds the content SHA-256 and rejects changed bytes. The CLI adapter remains available.
|
|
104
|
+
|
|
105
|
+
Startup: M365 CLI uses `version --output json`; M365 HTTP `ensureReady()` uses Graph `/me`; GWS CLI uses `--version`; GWS HTTP `ensureReady()` uses Gmail profile. Forbidden: `login`, `setup`, `auth`, `schema`, `doctor`, `--debug`, `--verbose`, credentials in argv, anonymous share, model-supplied command strings / URLs / free-form Discovery.
|
|
89
106
|
|
|
90
107
|
### Draft → approve → execute (0.7.0, R02)
|
|
91
108
|
|
|
@@ -99,6 +116,7 @@ In Prism 0.7.0, draft lifecycles are durably managed:
|
|
|
99
116
|
- **Resuming approved drafts**: Mutation tools accept `{ draftId, revision }` without requiring callers to re-supply the full payload. The tool loads the stored draft, validates approval status and digest, reauthorizes immediately before execution, and executes the effect.
|
|
100
117
|
- **Idempotent duplicate approvals**: Re-approving an approved draft with the same approval object is idempotent. Submitting an approval with a mismatched revision or payload digest is rejected with `ERR_PRISM_WORK_DRAFT_STALE` or `ERR_PRISM_WORK_DRAFT_DIGEST`.
|
|
101
118
|
- **Ambiguous failure handling**: If a connector call fails ambiguously after dispatch, both the idempotency record and the draft are marked `unknown`. Re-running with that draft ID or idempotency key fails closed (`ERR_PRISM_WORK_IDEMPOTENCY_UNKNOWN`) and never auto-replays without explicit operator reconciliation.
|
|
119
|
+
- **File-byte binding**: `*_file_draft_upload` accepts a host-local path, `ArtifactBodyRef`, or contained sandbox path. Its payload digest includes `contentHash`; execution re-hashes bytes and rejects a changed source. Artifact reads verify their hash/size through `ArtifactBodyStore`.
|
|
102
120
|
- **Optional body offloading**: Supplying `bodies: ArtifactBodyStore` automatically stores large draft message/file bodies in the object store with an `ArtifactBodyRef` recorded on the draft metadata.
|
|
103
121
|
|
|
104
122
|
### Durable idempotency (0.0.23)
|
|
@@ -116,6 +134,8 @@ In Prism 0.7.0, draft lifecycles are durably managed:
|
|
|
116
134
|
|
|
117
135
|
Call `begin({ identity, key, op })` **before** the external effect. After it succeeds, call `complete`, `fail`, or `markUnknown` with the returned claim token and version. The connector effect stays outside the database transaction, so this is claim-before-effect/deduplication—not exactly-once delivery. Claims default to 15 minutes (hard 60 minutes); expired claims transition to `unknown`; attempts default to 3 (hard 5). Stored rows contain no request body, token, raw provider response, or unrestricted payload.
|
|
118
136
|
|
|
137
|
+
Durable adapters reject with the portable codes `ERR_PRISM_WORK_IDEMPOTENCY` (a claim or payload the adapter refuses) and `ERR_PRISM_WORK_IDEMPOTENCY_CONFLICT` (a lost race, a stale claim token, or a transition out of order). Match on `error.code`: the error *class* is adapter-specific — the in-memory store raises `WorkToolError`, `createPostgresEnterpriseState(...).workIdempotency` raises `EnterprisePostgresError`, because `@arnilo/prism-core` cannot depend on `@arnilo/prism-work` at runtime — so an `instanceof` check that worked against the pre-move import path will silently stop matching. `packages/prism-core/src/enterprise/postgres/__tests__/work-idempotency.integration.test.ts` drives both adapters through the same conflict scenarios and asserts they report the same codes.
|
|
138
|
+
|
|
119
139
|
## Subprocess environment isolation (0.2.0, plan 020 Task 3)
|
|
120
140
|
|
|
121
141
|
`createCliRunner` never inherits the host environment. The child process receives only:
|
|
@@ -145,6 +165,7 @@ Environment maps are validated before spawn: NUL-free, `[A-Za-z_][A-Za-z0-9_]*`
|
|
|
145
165
|
| Pagination pages | 20 / 100 |
|
|
146
166
|
| Items / aggregate | 50/500 ; 200/2000 |
|
|
147
167
|
| Body / stdout | 256 KiB–2 MiB / 2–16 MiB |
|
|
168
|
+
| Download / upload file | 10 MiB / 50 MiB |
|
|
148
169
|
| Process wall time | 60 s / 10 min |
|
|
149
170
|
| Concurrent CLI / identity | 2 / 8 |
|
|
150
171
|
|
|
@@ -155,9 +176,10 @@ Approved mutations require core-derived `context.idempotencyKey` and a configure
|
|
|
155
176
|
## Security
|
|
156
177
|
|
|
157
178
|
- Require host-verified `AgentIdentity`; no cross-identity configDir reuse.
|
|
158
|
-
- Connector tokens
|
|
179
|
+
- Connector tokens: a `tokenProvider` resolves a per-identity access token only at the connector edge — into CLI env for CLI adapters or an `Authorization` header for HTTP adapters, never argv or model context. A missing/expired/revoked/cross-identity/wrong-tenant token fails the call closed before dispatch. Refresh is late-bound and single-flighted per account. Build one with `createOAuthWorkTokenProvider()` from `@arnilo/prism-core/credentials/node`.
|
|
159
180
|
- External mail recipients fail closed unless `externalRecipients.allow` returns true.
|
|
160
181
|
- Anonymous / `anyone` sharing denied.
|
|
182
|
+
- File gets accept IDs, never URLs; their response stream is cancelled at `maxFileBytes`, scanned before persistence, and returned only as artifact/path metadata with `untrusted: true`.
|
|
161
183
|
- CLI stdout/stderr capped (linear chunk capture, killed/rejected before bytes beyond the cap are retained); NDJSON page streams strictly parsed and page-capped; process killed on timeout/abort/overflow.
|
|
162
184
|
- Subprocess environment isolated (0.2.0): fixed allow-listed base + explicit `env` + late-bound token env; `HOME`/telemetry controls forced; reserved/duplicate/NUL/over-cap env and non-absolute binary/configDir fail before spawn. See [Subprocess environment isolation](#subprocess-environment-isolation-020-plan-020-task-3).
|
|
163
185
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arnilo/prism",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "Agent harness for AI providers, agents, sessions, and tools.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -125,9 +125,10 @@
|
|
|
125
125
|
"packages/mcp",
|
|
126
126
|
"packages/prism-providers",
|
|
127
127
|
"packages/memory",
|
|
128
|
+
"packages/prism-work",
|
|
128
129
|
"packages/prism-core",
|
|
130
|
+
"packages/prism-channels",
|
|
129
131
|
"packages/prism-coding-tools",
|
|
130
|
-
"packages/office",
|
|
131
132
|
"packages/ag-ui",
|
|
132
133
|
"packages/web-tools",
|
|
133
134
|
"packages/acp-agent"
|
|
@@ -146,7 +147,8 @@
|
|
|
146
147
|
"format": "biome format --write .",
|
|
147
148
|
"format:check": "biome format .",
|
|
148
149
|
"pack:dry-run": "npm pack --dry-run && npm run pack:dry-run --workspaces --if-present",
|
|
149
|
-
"test:postgres": "node scripts/
|
|
150
|
+
"test:postgres": "node scripts/postgres-evidence.mjs",
|
|
151
|
+
"test:postgres:run": "node scripts/require-postgres-url.mjs && npm run test:postgres --workspace @arnilo/prism-core --if-present && npm run test:postgres --workspace @arnilo/prism-memory && npm run test:postgres --workspace @arnilo/prism-channels && node --test scripts/phase7-conformance.test.mjs scripts/phase12-restart-recovery.test.mjs scripts/phase22-conformance.test.mjs",
|
|
150
152
|
"test:nats": "node scripts/require-nats-url.mjs && npm run test:nats --workspace @arnilo/prism-core --if-present",
|
|
151
153
|
"release:dry-run": "npm run sdk:ready",
|
|
152
154
|
"release:check": "node scripts/release.mjs check",
|
|
@@ -10,7 +10,7 @@ import {
|
|
|
10
10
|
providerTextDelta,
|
|
11
11
|
} from "@arnilo/prism";
|
|
12
12
|
import { createJsonSchemaArgumentValidator } from "@arnilo/prism-core/validation/json-schema";
|
|
13
|
-
import { createMemoryWorkDraftStore, type SyncWorkDraftStore } from "@arnilo/prism-
|
|
13
|
+
import { createMemoryWorkDraftStore, type SyncWorkDraftStore } from "@arnilo/prism-work/connectors";
|
|
14
14
|
import type { AgentIdentity } from "@arnilo/prism";
|
|
15
15
|
|
|
16
16
|
export interface CreateBusinessWorkerOptions {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import assert from "node:assert/strict";
|
|
2
2
|
import { describe, it } from "node:test";
|
|
3
3
|
import { assertHostCompositionReadiness, inspectHostComposition, HostCompositionError } from "@arnilo/prism";
|
|
4
|
-
import { validateApproval } from "@arnilo/prism-
|
|
4
|
+
import { validateApproval } from "@arnilo/prism-work/connectors";
|
|
5
5
|
import type { AgentIdentity } from "@arnilo/prism";
|
|
6
6
|
import { createAppAgent, createWorkerDraftStore } from "../agent.js";
|
|
7
7
|
|