@datalayer/agent-runtimes 1.3.111 → 1.3.112

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.
Files changed (44) hide show
  1. package/dist-embed/datalayer-app-main.js +4 -4
  2. package/lib/apps/apps/appspec.js +2 -0
  3. package/lib/apps/apps/checks.js +10 -6
  4. package/lib/examples/PapSignInDisplayExample.d.ts +4 -0
  5. package/lib/examples/PapSignInDisplayExample.js +23 -0
  6. package/lib/examples/example-selector.js +1 -0
  7. package/lib/examples/index.d.ts +1 -0
  8. package/lib/examples/index.js +1 -0
  9. package/lib/examples/main.js +2 -0
  10. package/lib/examples/pap/PapSignInDisplayView.d.ts +15 -0
  11. package/lib/examples/pap/PapSignInDisplayView.js +49 -0
  12. package/lib/examples/pap/PapTraceView.d.ts +2 -3
  13. package/lib/examples/pap/PapTraceView.js +3 -4
  14. package/lib/examples/pap/papSignInCases.d.ts +12 -0
  15. package/lib/examples/pap/papSignInCases.js +88 -0
  16. package/lib/protocols/a2a/index.d.ts +52 -0
  17. package/lib/protocols/a2a/index.js +164 -0
  18. package/lib/protocols/agentProtocols.d.ts +15 -0
  19. package/lib/protocols/agentProtocols.js +47 -0
  20. package/lib/protocols/agentic-commerce/index.d.ts +86 -0
  21. package/lib/protocols/agentic-commerce/index.js +267 -0
  22. package/lib/protocols/agentic-commerce/models.d.ts +3292 -0
  23. package/lib/protocols/agentic-commerce/models.js +10 -0
  24. package/lib/protocols/commerce.d.ts +42 -0
  25. package/lib/protocols/commerce.js +47 -0
  26. package/lib/protocols/core.d.ts +44 -0
  27. package/lib/protocols/core.js +62 -0
  28. package/lib/protocols/mcp/index.d.ts +4 -0
  29. package/lib/protocols/mcp/index.js +37 -0
  30. package/lib/protocols/pact/index.d.ts +139 -0
  31. package/lib/protocols/pact/index.js +357 -0
  32. package/lib/protocols/ucp/index.d.ts +79 -0
  33. package/lib/protocols/ucp/index.js +277 -0
  34. package/lib/protocols/web-bot-auth/index.d.ts +161 -0
  35. package/lib/protocols/web-bot-auth/index.js +427 -0
  36. package/lib/specs/actions.js +4 -0
  37. package/lib/specs/apps.d.ts +2 -0
  38. package/lib/specs/apps.js +481 -0
  39. package/lib/specs/appspecSchema.js +200 -2
  40. package/lib/types/agentspecs.d.ts +2 -0
  41. package/package.json +4 -1
  42. package/scripts/codegen/generate_agentic_commerce.sh +74 -0
  43. package/scripts/codegen/generate_apps.py +11 -0
  44. package/scripts/validate_pap_examples.py +27 -2
@@ -0,0 +1,10 @@
1
+ /*
2
+ * Copyright (c) 2025-2026 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ // GENERATED — do not edit. The Agentic Commerce Protocol 2026-04-17, its checkout
6
+ // types: json-schema-to-typescript 15.0.4 over
7
+ // agentic-commerce-protocol/agentic-commerce-protocol spec/2026-04-17/json-schema/
8
+ // schema.agentic_checkout.json (Apache 2.0). Regenerate with
9
+ // scripts/codegen/generate_agentic_commerce.sh.
10
+ export const AGENTIC_COMMERCE_VERSION = '2026-04-17';
@@ -0,0 +1,42 @@
1
+ /**
2
+ * What every commerce protocol shares (AGENT_PROTOCOLS §3, one approval
3
+ * model) — the twin of `agent_runtimes.protocols.commerce`. A purchase over
4
+ * UCP or the Agentic Commerce Protocol is an exact, revisioned
5
+ * {@link CheckoutProposal}, approved by the person through the host's
6
+ * {@link CheckoutApprover} (contributed to each plugin's `<protocol>.approver`),
7
+ * and completed once ({@link ProposalStore}).
8
+ *
9
+ * @module protocols/commerce
10
+ */
11
+ type Json = Record<string, any>;
12
+ /** One exact purchase, proposed to a person before it is made. */
13
+ export interface CheckoutProposal {
14
+ id: string;
15
+ merchant: string;
16
+ checkoutId: string;
17
+ /** SHA-256 of what is bought: lines, prices, quantities, totals, currency. */
18
+ revision: string;
19
+ currency: string;
20
+ total: number;
21
+ lines: Array<{
22
+ title: string;
23
+ quantity: number;
24
+ price: number;
25
+ }>;
26
+ expiresAt?: string;
27
+ }
28
+ /** A proposal in words, for the person and the model: never a credential. */
29
+ export declare function proposalSummary(proposal: CheckoutProposal): string;
30
+ export interface CheckoutApprover {
31
+ approve(proposal: CheckoutProposal): Promise<boolean>;
32
+ }
33
+ export interface ProposalStore {
34
+ take(proposalId: string): Promise<boolean>;
35
+ }
36
+ export declare class InMemoryProposalStore implements ProposalStore {
37
+ private taken;
38
+ take(proposalId: string): Promise<boolean>;
39
+ }
40
+ /** The SHA-256 of a canonical JSON (sorted keys, no spaces): a proposal's revision. */
41
+ export declare function digest(what: Json): Promise<string>;
42
+ export {};
@@ -0,0 +1,47 @@
1
+ /*
2
+ * Copyright (c) 2025-2026 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /** A proposal in words, for the person and the model: never a credential. */
6
+ export function proposalSummary(proposal) {
7
+ const items = proposal.lines
8
+ .map(line => `${line.quantity} × ${line.title}`)
9
+ .join(', ');
10
+ const amount = (proposal.total / 100).toLocaleString('en-US', {
11
+ minimumFractionDigits: 2,
12
+ maximumFractionDigits: 2,
13
+ });
14
+ return `Buy ${items} at ${proposal.merchant} for ${proposal.currency} ${amount}`;
15
+ }
16
+ export class InMemoryProposalStore {
17
+ taken = new Set();
18
+ async take(proposalId) {
19
+ if (this.taken.has(proposalId)) {
20
+ return false;
21
+ }
22
+ this.taken.add(proposalId);
23
+ return true;
24
+ }
25
+ }
26
+ /** The SHA-256 of a canonical JSON (sorted keys, no spaces): a proposal's revision. */
27
+ export function digest(what) {
28
+ return sha256(canonical(what));
29
+ }
30
+ async function sha256(text) {
31
+ const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(text));
32
+ return [...new Uint8Array(digest)]
33
+ .map(b => b.toString(16).padStart(2, '0'))
34
+ .join('');
35
+ }
36
+ function canonical(value) {
37
+ if (Array.isArray(value)) {
38
+ return `[${value.map(canonical).join(',')}]`;
39
+ }
40
+ if (value && typeof value === 'object') {
41
+ return `{${Object.keys(value)
42
+ .sort()
43
+ .map(key => `${JSON.stringify(key)}:${canonical(value[key])}`)
44
+ .join(',')}}`;
45
+ }
46
+ return JSON.stringify(value ?? null);
47
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * The agent protocols, each a Reactor Plugin (AGENT_PROTOCOLS §3.1, decided
3
+ * 2026-10-12) — the TypeScript twin of `agent_runtimes.protocols`.
4
+ *
5
+ * Every protocol is a Plugin declaring its Contribution Points
6
+ * (`<protocol>.<point>`), its defaults contributed at order 100 that a host
7
+ * replaces with a lower order; every extension a protocol defines is a
8
+ * Contribution Point of its plugin (`<protocol>.extension.<name>`), an
9
+ * implementation a Contribution to it. The `agent-protocols` Reactor
10
+ * Extension only groups the plugins for delivery. Each protocol's
11
+ * `reactor-points.json` holds both languages to the same points.
12
+ *
13
+ * @module protocols/core
14
+ */
15
+ import { type ContributionPoint, type ReactorPlatformView } from '@datalayer/reactor';
16
+ /** The order of a plugin's own defaults; a host contributes lower to replace one. */
17
+ export declare const DEFAULT_ORDER = 100;
18
+ /** One protocol as its plugin implements it. */
19
+ export interface ProtocolDescription {
20
+ id: string;
21
+ name: string;
22
+ layer: 'transport' | 'consent' | 'identity' | 'commerce';
23
+ /** The specification version implemented. */
24
+ version: string;
25
+ roles: string[];
26
+ status: 'implemented' | 'partial' | 'planned';
27
+ specification: string;
28
+ plugin: string;
29
+ /** The contribution points its plugin declares, its extensions' included. */
30
+ points: string[];
31
+ }
32
+ /** Where each protocol plugin says what it is. */
33
+ export declare const ProtocolDescriptions: ContributionPoint<ProtocolDescription>;
34
+ /** The plugin that declares {@link ProtocolDescriptions}; it contributes nothing. */
35
+ export declare const ProtocolsCorePlugin: import("@datalayer/reactor").ReactorPlugin<Record<string, never>, unknown, unknown>;
36
+ /**
37
+ * The lowest-order contribution to a single-provider point. None, or two at
38
+ * the same winning order, fails closed.
39
+ */
40
+ export declare function firstContribution<T>(reactor: ReactorPlatformView, point: ContributionPoint<T>, label: string): T;
41
+ /** As {@link firstContribution}, `undefined` when nothing is contributed. */
42
+ export declare function optionalContribution<T>(reactor: ReactorPlatformView, point: ContributionPoint<T>, label: string): T | undefined;
43
+ /** What the protocol plugins say they are, one per protocol, by id. */
44
+ export declare function listProtocols(reactor: ReactorPlatformView): ProtocolDescription[];
@@ -0,0 +1,62 @@
1
+ /*
2
+ * Copyright (c) 2025-2026 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /**
6
+ * The agent protocols, each a Reactor Plugin (AGENT_PROTOCOLS §3.1, decided
7
+ * 2026-10-12) — the TypeScript twin of `agent_runtimes.protocols`.
8
+ *
9
+ * Every protocol is a Plugin declaring its Contribution Points
10
+ * (`<protocol>.<point>`), its defaults contributed at order 100 that a host
11
+ * replaces with a lower order; every extension a protocol defines is a
12
+ * Contribution Point of its plugin (`<protocol>.extension.<name>`), an
13
+ * implementation a Contribution to it. The `agent-protocols` Reactor
14
+ * Extension only groups the plugins for delivery. Each protocol's
15
+ * `reactor-points.json` holds both languages to the same points.
16
+ *
17
+ * @module protocols/core
18
+ */
19
+ import { defineContributionPoint, definePlugin, } from '@datalayer/reactor';
20
+ /** The order of a plugin's own defaults; a host contributes lower to replace one. */
21
+ export const DEFAULT_ORDER = 100;
22
+ /** Where each protocol plugin says what it is. */
23
+ export const ProtocolDescriptions = defineContributionPoint('protocols.description');
24
+ /** The plugin that declares {@link ProtocolDescriptions}; it contributes nothing. */
25
+ export const ProtocolsCorePlugin = definePlugin({
26
+ name: 'agent-runtimes.protocols',
27
+ version: '1.0.0',
28
+ description: 'What the agent protocols say they are.',
29
+ contributionPoints: [ProtocolDescriptions],
30
+ });
31
+ /**
32
+ * The lowest-order contribution to a single-provider point. None, or two at
33
+ * the same winning order, fails closed.
34
+ */
35
+ export function firstContribution(reactor, point, label) {
36
+ const contributions = reactor.getContributions(point);
37
+ const [first, second] = contributions;
38
+ if (!first) {
39
+ throw new Error(`no ${label} is contributed (${point.id})`);
40
+ }
41
+ if (second && second.order === first.order) {
42
+ throw new Error(`two ${label}s are contributed at the same order (${point.id})`);
43
+ }
44
+ return first.value;
45
+ }
46
+ /** As {@link firstContribution}, `undefined` when nothing is contributed. */
47
+ export function optionalContribution(reactor, point, label) {
48
+ if (!reactor.getContributions(point).length) {
49
+ return undefined;
50
+ }
51
+ return firstContribution(reactor, point, label);
52
+ }
53
+ /** What the protocol plugins say they are, one per protocol, by id. */
54
+ export function listProtocols(reactor) {
55
+ const byId = new Map();
56
+ for (const contribution of [
57
+ ...reactor.getContributions(ProtocolDescriptions),
58
+ ].reverse()) {
59
+ byId.set(contribution.value.id, contribution.value);
60
+ }
61
+ return [...byId.values()].sort((a, b) => a.id.localeCompare(b.id));
62
+ }
@@ -0,0 +1,4 @@
1
+ export declare const MCP_PLUGIN = "agent-runtimes.protocols.mcp";
2
+ /** The MCP specification version of the `@modelcontextprotocol/sdk` installed (1.32: `LATEST_PROTOCOL_VERSION`); Python's `mcp` 2.1 speaks 2026-07-28. */
3
+ export declare const MCP_SPECIFICATION_VERSION = "2025-11-25";
4
+ export declare const McpPlugin: import("@datalayer/reactor").ReactorPlugin<Record<string, never>, unknown, unknown>;
@@ -0,0 +1,37 @@
1
+ /*
2
+ * Copyright (c) 2025-2026 Datalayer, Inc.
3
+ * Distributed under the terms of the Modified BSD License.
4
+ */
5
+ /**
6
+ * MCP as a Reactor Plugin. It says what it is on `protocols.description` and
7
+ * declares no point yet: MCP's optional capabilities and extensions become
8
+ * `mcp.extension.<name>` points when the MCP client and server read them
9
+ * from contributions (AGENT_PROTOCOLS PR-01). The twin of
10
+ * `agent_runtimes.protocols.mcp`.
11
+ *
12
+ * @module protocols/mcp
13
+ */
14
+ import { contribution, definePlugin } from '@datalayer/reactor';
15
+ import { DEFAULT_ORDER, ProtocolDescriptions } from '../core';
16
+ export const MCP_PLUGIN = 'agent-runtimes.protocols.mcp';
17
+ /** The MCP specification version of the `@modelcontextprotocol/sdk` installed (1.32: `LATEST_PROTOCOL_VERSION`); Python's `mcp` 2.1 speaks 2026-07-28. */
18
+ export const MCP_SPECIFICATION_VERSION = '2025-11-25';
19
+ export const McpPlugin = definePlugin({
20
+ name: MCP_PLUGIN,
21
+ version: '1.0.0',
22
+ description: 'Model Context Protocol: tools, resources and prompts.',
23
+ contributionPoints: [],
24
+ contributes: [
25
+ contribution(ProtocolDescriptions, {
26
+ id: 'mcp',
27
+ name: 'Model Context Protocol',
28
+ layer: 'transport',
29
+ version: MCP_SPECIFICATION_VERSION,
30
+ roles: ['client', 'server'],
31
+ status: 'implemented',
32
+ specification: 'https://modelcontextprotocol.io/specification',
33
+ plugin: MCP_PLUGIN,
34
+ points: [],
35
+ }, { id: 'mcp', order: DEFAULT_ORDER }),
36
+ ],
37
+ });
@@ -0,0 +1,139 @@
1
+ /**
2
+ * PACT 1.0, Personal Agent Consent & Trust, as a Reactor Plugin and a
3
+ * personal agent (AGENT_PROTOCOLS PR-10 to PR-13) — the twin of
4
+ * `agent_runtimes.protocols.pact`. Built against
5
+ * `openpactprotocol/openpactprotocol` `docs/spec.md` at 838c6bd
6
+ * (2026-10-06), reviewed 2026-10-12.
7
+ *
8
+ * The personal-agent JWT (§3.2) is signed by the host's key through
9
+ * `pact.signer` (ES256, the Web Bot Auth signer's contract); the delegation
10
+ * token (§5) is kept in `pact.delegationStore`, never handed to the agent;
11
+ * every receipt (§5.6) is verified with `jose` before it is kept in
12
+ * `pact.receiptStore`.
13
+ *
14
+ * @module protocols/pact
15
+ */
16
+ import { type ReactorPlatformView } from '@datalayer/reactor';
17
+ import type { HttpSigner } from '../web-bot-auth';
18
+ export declare const PACT_VERSION = "1.0";
19
+ export declare const PACT_PLUGIN = "agent-runtimes.protocols.pact";
20
+ export declare const DELEGATION_HEADER = "X-A2A-User-Delegation";
21
+ export declare const DEVICE_CODE_GRANT = "urn:ietf:params:oauth:grant-type:device_code";
22
+ type Json = Record<string, any>;
23
+ export declare class PactError extends Error {
24
+ }
25
+ /** A scope a Brand offers, and its action class (F-10): unknown is the most restricted. */
26
+ export interface PactScope {
27
+ id: string;
28
+ description: string;
29
+ actionClass: 'read' | 'write';
30
+ }
31
+ export interface PactCard {
32
+ name: string;
33
+ interfaceUrl: string;
34
+ identityScheme: string;
35
+ profile: 'identity' | 'delegated';
36
+ delegation?: {
37
+ deviceAuthorizationUrl: string;
38
+ tokenUrl: string;
39
+ metadataUrl: string;
40
+ scopes: PactScope[];
41
+ };
42
+ }
43
+ export interface DelegationStore {
44
+ put(brand: string, user: string, token: string, scopes: string[]): Promise<void>;
45
+ get(brand: string, user: string): Promise<{
46
+ token: string;
47
+ scopes: string[];
48
+ } | undefined>;
49
+ delete(brand: string, user: string): Promise<void>;
50
+ }
51
+ export interface ReceiptStore {
52
+ keep(brand: string, user: string, claims: Json): Promise<void>;
53
+ }
54
+ export interface DelegatedProfile {
55
+ grantType: string;
56
+ }
57
+ export declare class InMemoryDelegationStore implements DelegationStore {
58
+ private held;
59
+ put(brand: string, user: string, token: string, scopes: string[]): Promise<void>;
60
+ get(brand: string, user: string): Promise<{
61
+ token: string;
62
+ scopes: string[];
63
+ } | undefined>;
64
+ delete(brand: string, user: string): Promise<void>;
65
+ }
66
+ export declare class InMemoryReceiptStore implements ReceiptStore {
67
+ readonly receipts: Array<{
68
+ brand: string;
69
+ user: string;
70
+ claims: Json;
71
+ }>;
72
+ keep(brand: string, user: string, claims: Json): Promise<void>;
73
+ }
74
+ export declare const PactSigners: import("@datalayer/reactor").ContributionPoint<HttpSigner>;
75
+ export declare const PactDelegationStores: import("@datalayer/reactor").ContributionPoint<DelegationStore>;
76
+ export declare const PactReceiptStores: import("@datalayer/reactor").ContributionPoint<ReceiptStore>;
77
+ export declare const PactDelegatedProfiles: import("@datalayer/reactor").ContributionPoint<DelegatedProfile>;
78
+ export declare const PactPlugin: import("@datalayer/reactor").ReactorPlugin<Record<string, never>, unknown, unknown>;
79
+ /** A Brand's card as PACT 1.0 reads it (§2.1, §5.1); throws when it is not one. */
80
+ export declare function readCard(card: Json): PactCard;
81
+ /** One personal-agent JWT (§3.2): ES256 by the host's signer, `sub` opaque, ≤ 300 s. */
82
+ export declare function signPersonalAgentJwt(signer: HttpSigner | {
83
+ keyid: string;
84
+ algorithm: string;
85
+ sign(data: Uint8Array): Promise<Uint8Array>;
86
+ }, claims: {
87
+ issuer: string;
88
+ subject: string;
89
+ audience: string;
90
+ lifetime?: number;
91
+ }): Promise<string>;
92
+ export type Reply = {
93
+ kind: 'reply';
94
+ text: string;
95
+ contextId: string;
96
+ scopesUsed: string[];
97
+ actions: string[];
98
+ };
99
+ export type StepUp = {
100
+ kind: 'step-up';
101
+ text: string;
102
+ contextId: string;
103
+ missing: string[];
104
+ verificationUri: string;
105
+ };
106
+ /** What the person is shown to sign in at the Brand: never the device code. */
107
+ export type SignIn = {
108
+ verificationUri: string;
109
+ userCode: string;
110
+ expiresIn: number;
111
+ reference: string;
112
+ };
113
+ /** A personal agent at one Brand. */
114
+ export declare class PactPersonalAgent {
115
+ private readonly options;
116
+ card?: PactCard;
117
+ private pending;
118
+ private jwks?;
119
+ constructor(options: {
120
+ cardUrl: string;
121
+ issuer: string;
122
+ audience: string;
123
+ reactor: ReactorPlatformView;
124
+ fetchImpl?: typeof fetch;
125
+ });
126
+ private get fetch();
127
+ private jwt;
128
+ private delegations;
129
+ discover(): Promise<PactCard>;
130
+ send(user: string, text: string, options?: {
131
+ contextId?: string;
132
+ messageId?: string;
133
+ }): Promise<Reply | StepUp>;
134
+ private verifyReceipt;
135
+ requestSignIn(user: string, scopes: string[]): Promise<SignIn>;
136
+ /** Poll until the person approved; the scopes they actually granted. */
137
+ finishSignIn(user: string, signIn: SignIn, intervalMs?: number, attempts?: number): Promise<string[]>;
138
+ }
139
+ export {};