@datalayer/agent-runtimes 1.5.96 → 1.5.97

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 (92) hide show
  1. package/dist-embed/chunks/{index.esm-zOy6kFPv.js → index.esm-BLDeC6q1.js} +1 -1
  2. package/dist-embed/datalayer-app-main.js +80 -80
  3. package/lib/apps/apps/appspec.d.ts +11 -12
  4. package/lib/apps/apps/appspec.js +45 -87
  5. package/lib/components/cards/ToolApprovalCard.js +4 -2
  6. package/lib/components/teams/HarnessIcon.d.ts +11 -0
  7. package/lib/components/teams/HarnessIcon.js +17 -0
  8. package/lib/components/teams/SceneTranscript.d.ts +1 -1
  9. package/lib/components/teams/SceneTranscript.js +12 -7
  10. package/lib/components/teams/SceneView.d.ts +7 -1
  11. package/lib/components/teams/SceneView.js +2 -2
  12. package/lib/components/teams/backdrops/hero.js +1 -1
  13. package/lib/components/teams/backdrops/minimal.js +1 -1
  14. package/lib/components/teams/backdrops/nodes.js +4 -3
  15. package/lib/components/teams/backdrops/space.js +1 -1
  16. package/lib/components/teams/backdrops/types.d.ts +9 -0
  17. package/lib/components/teams/index.d.ts +2 -0
  18. package/lib/components/teams/index.js +2 -0
  19. package/lib/components/teams/memberHarness.d.ts +16 -0
  20. package/lib/components/teams/memberHarness.js +42 -0
  21. package/lib/components/teams/sceneTranscriptRules.js +6 -1
  22. package/lib/components/teams/transcript/LineSelect.d.ts +20 -0
  23. package/lib/components/teams/transcript/LineSelect.js +20 -0
  24. package/lib/components/teams/transcript/TranscriptTable.d.ts +11 -5
  25. package/lib/components/teams/transcript/TranscriptTable.js +24 -7
  26. package/lib/components/teams/transcript/TranscriptViews.js +1 -1
  27. package/lib/components/teams/transcript/recordingPlayback.d.ts +13 -0
  28. package/lib/components/teams/transcript/recordingPlayback.js +32 -0
  29. package/lib/components/teams/transcript/useSceneRecording.d.ts +1 -1
  30. package/lib/components/teams/transcript/useSceneRecording.js +19 -11
  31. package/lib/examples/PapAccountTokensExample.d.ts +1 -1
  32. package/lib/examples/PapAccountTokensExample.js +3 -3
  33. package/lib/examples/PapSessionJwtExample.d.ts +4 -0
  34. package/lib/examples/{PapDpopProofExample.js → PapSessionJwtExample.js} +9 -9
  35. package/lib/examples/PapSessionLifecycleExample.d.ts +1 -1
  36. package/lib/examples/PapSessionLifecycleExample.js +2 -2
  37. package/lib/examples/ScenesExample.js +15 -13
  38. package/lib/examples/example-selector.js +3 -3
  39. package/lib/examples/index.d.ts +1 -1
  40. package/lib/examples/index.js +1 -1
  41. package/lib/examples/main.js +1 -1
  42. package/lib/examples/pap/PapAccountTokensView.d.ts +1 -1
  43. package/lib/examples/pap/PapAuthorizationBoundaryView.js +15 -22
  44. package/lib/examples/pap/PapGuidedJourneyView.js +61 -60
  45. package/lib/examples/pap/PapSessionJwtView.d.ts +4 -0
  46. package/lib/examples/pap/PapSessionJwtView.js +69 -0
  47. package/lib/examples/pap/PapSessionLifecycleView.js +36 -58
  48. package/lib/examples/pap/PapSignInDisplayView.d.ts +1 -1
  49. package/lib/examples/pap/PapSignInDisplayView.js +1 -1
  50. package/lib/examples/pap/PapTraceView.d.ts +1 -1
  51. package/lib/examples/pap/PapTraceView.js +1 -1
  52. package/lib/examples/pap/traces/account-tokens.json +145 -173
  53. package/lib/examples/pap/traces/conversation-control.json +118 -140
  54. package/lib/examples/pap/traces/conversation-streaming.json +114 -134
  55. package/lib/examples/pap/traces/mediated-sign-in.json +151 -166
  56. package/lib/examples/pap/traces/operations.json +613 -391
  57. package/lib/examples/pap/traces/two-companies.json +380 -990
  58. package/lib/examples/pap/traces/user-with-a-company.json +319 -207
  59. package/lib/models/environments.generated.d.ts +2 -2
  60. package/lib/models/environments.generated.js +1 -1
  61. package/lib/pap/index.d.ts +1 -1
  62. package/lib/pap/index.js +3 -3
  63. package/lib/portable/displays.d.ts +13 -22
  64. package/lib/portable/displays.js +17 -65
  65. package/lib/portable/hosts/approvalRenderers.d.ts +4 -4
  66. package/lib/portable/hosts/approvalRenderers.js +26 -13
  67. package/lib/portable/hosts/contracts.json +5 -2
  68. package/lib/portable/index.d.ts +1 -1
  69. package/lib/portable/index.js +1 -1
  70. package/lib/protocols/decks/index.d.ts +37 -0
  71. package/lib/protocols/decks/index.js +48 -0
  72. package/lib/protocols/decks/pact-a-personal-agent-at-a-business.d.ts +2 -0
  73. package/lib/protocols/decks/pact-a-personal-agent-at-a-business.js +148 -0
  74. package/lib/protocols/decks/ucp-a-purchase-approved.d.ts +2 -0
  75. package/lib/protocols/decks/ucp-a-purchase-approved.js +154 -0
  76. package/lib/specs/actions.d.ts +1 -1
  77. package/lib/specs/actions.js +2 -2
  78. package/lib/specs/agents/agents.js +3 -3
  79. package/lib/specs/apps.d.ts +1 -1
  80. package/lib/specs/apps.js +10 -11
  81. package/lib/specs/appspecSchema.js +4 -112
  82. package/lib/specs/envvars.js +2 -2
  83. package/lib/specs/harnesses.js +9 -9
  84. package/lib/specs/scenes.js +10 -33
  85. package/lib/specs/teams/teams.js +2 -2
  86. package/lib/types/agentspecs.d.ts +91 -127
  87. package/package.json +409 -409
  88. package/scripts/codegen/generate_apps.py +6 -7
  89. package/scripts/validate_pap_examples.py +1 -1
  90. package/lib/examples/PapDpopProofExample.d.ts +0 -4
  91. package/lib/examples/pap/PapDpopProofView.d.ts +0 -4
  92. package/lib/examples/pap/PapDpopProofView.js +0 -61
@@ -37,7 +37,7 @@ import { ThemedProvider } from './utils/themedProvider.js';
37
37
  import { useBrowserInference } from '../hooks/useBrowserInference.js';
38
38
  import { useAnonymousSessionStore } from '../runtimes/browser/anonymousToken.js';
39
39
  import { connectA2APeer } from '../runtimes/browser/a2aPeer.js';
40
- import { A2ATeamGraph, appColorOf, NOTEBOOK_AND_WORDS, PERSON, SceneView, sceneCuesOf, sceneMemberUrl, sceneRuntimePorts, sceneStageOf, teamConnectionsOf, teamToolClassifier, useA2ATeam, useSceneTranscript, latestLineOnEdge, selectedEdgeOf, selectionOfLine, stageBackdropOf, SCENE_BACKDROP_CHOICES, } from '../components/teams/index.js';
40
+ import { A2ATeamGraph, appColorOf, NOTEBOOK_AND_WORDS, PERSON, SceneView, sceneCuesOf, sceneMemberUrl, sceneRuntimePorts, sceneStageOf, teamConnectionsOf, teamToolClassifier, useA2ATeam, useSceneTranscript, latestLineOnEdge, selectedEdgeOf, selectionOfLine, stageBackdropOf, SCENE_BACKDROP_CHOICES, memberAppDetails, } from '../components/teams/index.js';
41
41
  import { listSceneSpecs } from '../specs/scenes.js';
42
42
  import { classifyToolCall, traceA2AFetch, useAgentInspector, } from '../components/inspector/index.js';
43
43
  /** Where the members on a runtime are, by application id: the local ports, unless a variable says. */
@@ -151,11 +151,17 @@ function Scene({ scene, backdrop, }) {
151
151
  name: member.app.name,
152
152
  connections: runtimeMembers.find(one => one.id === member.id)?.connections ?? [],
153
153
  })), [stage, runtimeMembers]);
154
- // The exchange selected in the transcript, as the edge of the graph it is
155
- // on (S3-02): the graph draws it with a halo; a click on an edge selects
156
- // its latest exchange.
157
- const [selectedEdge, setSelectedEdge] = useState(null);
154
+ // The line selected, held here for the transcript and the graph (S3-02):
155
+ // the transcript opens it, the graph draws its edge with a halo, and a
156
+ // click on an edge selects its latest exchange.
157
+ const [selectedLine, setSelectedLine] = useState(null);
158
158
  const lines = useSceneTranscript(inspector, transcriptMembers);
159
+ const selectedEdge = useMemo(() => {
160
+ const line = lines.find(one => one.key === selectedLine);
161
+ return line
162
+ ? (selectedEdgeOf(selectionOfLine(line), transcriptMembers) ?? null)
163
+ : null;
164
+ }, [lines, selectedLine, transcriptMembers]);
159
165
  const whereOf = (member) => member.runsIn === 'browser'
160
166
  ? 'in your browser'
161
167
  : `on a runtime, ${new URL(runtimeMembers.find(one => one.id === member.id)?.url ?? 'http://runtime').host}`;
@@ -178,13 +184,14 @@ function Scene({ scene, backdrop, }) {
178
184
  return (_jsxs(Box, { "data-scene-example": scene.id, children: [_jsx(Text, { as: "p", sx: { color: 'fg.muted', mt: 0 }, "data-scene-assumes": "", children: stage.assumes }), anonymous.status === 'active' && anonymous.expiresAt && (_jsx(Box, { mb: 3, children: _jsx(AnonymousKeyTimer, { expiresAt: anonymous.expiresAt, grantedMs: anonymous.grantedMs, label: `${entry.app.name}'s trial key`, onExpire: () => useAnonymousSessionStore.getState().expire() }) })), anonymous.status === 'expired' && (_jsx(Box, { mb: 3, children: _jsx(AnonymousKeyExpired, { agentName: entry.app.name, onSignedIn: () => useAnonymousSessionStore.getState().clear() }) })), entryInBrowser && needsSignIn && (_jsxs(Flash, { variant: "warning", sx: { mb: 3 }, children: [entry.app.name, " asks its model through the Datalayer inference service: sign in, or wait for a visitor\u2019s trial key."] })), notReached.map(member => (_jsx(Flash, { variant: "danger", sx: { mb: 3 }, "data-scene-needs": member.app.id, children: memberNeeds(member, reachedOf(member.id).error ?? '').map(line => (_jsx(Text, { as: "p", sx: { m: 0 }, children: line }, line))) }, member.id))), runtimeMembers.map(member => (_jsx(ReachMember, { member: member,
179
185
  // Its requests are the entry's, or the person's own when the
180
186
  // page asks it itself.
181
- asker: member.entry ? PERSON : entry.app.name, tracer: inspector, onReached: onReached }, member.id))), _jsx(Box, { border: "1px solid", borderColor: "border.default", borderRadius: 2, bg: "canvas.subtle", px: 2, pt: 2, mb: 3, children: _jsx(SceneView, { members: transcriptMembers, tracer: inspector, onSelect: selection => setSelectedEdge(selectedEdgeOf(selection, transcriptMembers) ?? null), emptyText: `Nothing said yet: ask ${entry.app.name} with one of the suggestions.`, children: _jsx(A2ATeamGraph, { entry: {
187
+ asker: member.entry ? PERSON : entry.app.name, tracer: inspector, onReached: onReached }, member.id))), _jsx(Box, { border: "1px solid", borderColor: "border.default", borderRadius: 2, bg: "canvas.subtle", px: 2, pt: 2, mb: 3, children: _jsx(SceneView, { members: transcriptMembers, tracer: inspector, selected: selectedLine, onSelect: selection => setSelectedLine(selection?.key ?? null), emptyText: `Nothing said yet: ask ${entry.app.name} with one of the suggestions.`, children: _jsx(A2ATeamGraph, { entry: {
182
188
  id: entry.app.id,
183
189
  name: entry.app.name,
184
190
  emoji: entry.cast.persona.face || entry.app.emoji,
185
191
  character: avatarShown(entry.app.interface.avatar, 'paperclip'),
186
192
  color: appColorOf(entry.app),
187
193
  where: whereOf(entry),
194
+ ...memberAppDetails(entry.app, entry.runsIn),
188
195
  persona: team.entryPersona,
189
196
  onToggle: () => composer.current?.focus(),
190
197
  conversationLabel: `Ask ${entry.app.name}`,
@@ -210,6 +217,7 @@ function Scene({ scene, backdrop, }) {
210
217
  character: avatarShown(peer.app.interface.avatar, 'wizard'),
211
218
  color: appColorOf(peer.app),
212
219
  where: whereOf(peer),
220
+ ...memberAppDetails(peer.app, peer.runsIn),
213
221
  persona: kept?.persona ?? team.peerPersona,
214
222
  onAway: kept?.setAway,
215
223
  history: kept?.history,
@@ -238,13 +246,7 @@ function Scene({ scene, backdrop, }) {
238
246
  balloonRoom: 320,
239
247
  // Drawn as chosen above the tabs, else as the scene says:
240
248
  // studio, hero, plain, space, minimal or orb.
241
- backdrop: backdrop ?? stageBackdropOf(scene), selected: selectedEdge, onSelectEdge: edge => {
242
- const line = latestLineOnEdge(edge, lines, transcriptMembers);
243
- setSelectedEdge(line
244
- ? (selectedEdgeOf(selectionOfLine(line), transcriptMembers) ??
245
- null)
246
- : null);
247
- } }) }) }), _jsx(Box, { ref: notebookArea, mb: team.notebook ? 3 : 0, "data-team-notebook-placement": "under-graph" }), _jsxs(Box, { display: "flex", gap: 3, flexWrap: "wrap", children: [_jsxs(Box, { flex: "1 1 420px", minWidth: 0, children: [_jsxs(Heading, { as: "h3", sx: { fontSize: 2, mb: 2 }, children: ["Ask ", entry.app.name] }), _jsx(Text, { as: "p", sx: { color: 'fg.muted', fontSize: 1, mt: 0 }, children: "Or choose one of its suggestions in its balloon: the script\u2019s cues." }), _jsx(Textarea, { ref: composer, block: true, rows: 3, value: draft, placeholder: suggestions[0]?.prompt ?? 'Ask…', onChange: event => setDraft(event.target.value), onKeyDown: event => {
249
+ backdrop: backdrop ?? stageBackdropOf(scene), selected: selectedEdge, onSelectEdge: edge => setSelectedLine(latestLineOnEdge(edge, lines, transcriptMembers)?.key ?? null) }) }) }), _jsx(Box, { ref: notebookArea, mb: team.notebook ? 3 : 0, "data-team-notebook-placement": "under-graph" }), _jsxs(Box, { display: "flex", gap: 3, flexWrap: "wrap", children: [_jsxs(Box, { flex: "1 1 420px", minWidth: 0, children: [_jsxs(Heading, { as: "h3", sx: { fontSize: 2, mb: 2 }, children: ["Ask ", entry.app.name] }), _jsx(Text, { as: "p", sx: { color: 'fg.muted', fontSize: 1, mt: 0 }, children: "Or choose one of its suggestions in its balloon: the script\u2019s cues." }), _jsx(Textarea, { ref: composer, block: true, rows: 3, value: draft, placeholder: suggestions[0]?.prompt ?? 'Ask…', onChange: event => setDraft(event.target.value), onKeyDown: event => {
248
250
  if (event.key === 'Enter' && !event.shiftKey) {
249
251
  event.preventDefault();
250
252
  send(draft);
@@ -139,16 +139,16 @@ export const EXAMPLE_ENTRIES = [
139
139
  makeEntry('PapCompanyDiscoveryExample', () => import('./PapCompanyDiscoveryExample.js'), 'Validate a PAP company document and reduce it to the public capabilities safe for an agent or UI.'),
140
140
  makeEntry('PapAgentIdentityExample', () => import('./PapAgentIdentityExample.js'), 'Verify personal-agent client metadata and signing policy without exposing JWK coordinates.'),
141
141
  makeEntry('PapAuthorizationBoundaryExample', () => import('./PapAuthorizationBoundaryExample.js'), 'Generate real Session and Direct Sign-In security material while showing only safe policy status.'),
142
- makeEntry('PapDpopProofExample', () => import('./PapDpopProofExample.js'), 'Create fresh request-bound DPoP proofs while withholding proof, token, nonce, identifiers, and key material.'),
142
+ makeEntry('PapSessionJwtExample', () => import('./PapSessionJwtExample.js'), 'Create fresh request-bound Session JWTs while withholding the JWT, token, identifiers, and key material.'),
143
143
  makeEntry('PapSessionLifecycleExample', () => import('./PapSessionLifecycleExample.js'), 'Start, retry, and renew a signed-out PAP Session while credentials remain host-owned.'),
144
144
  makeEntry('PapGuidedJourneyExample', () => import('./PapGuidedJourneyExample.js'), 'Follow a visual PAP return journey across discovery, signed-out conversation, Direct Sign-In, and an exact user-authorized result.'),
145
145
  makeEntry('PapUserWithACompanyExample', () => import('./PapUserWithACompanyExample.js'), 'Replay, step by step, Ada, her personal agent and one company: question, Device Sign-In, the same conversation, and one exactly approved operation.'),
146
146
  makeEntry('PapTwoCompaniesExample', () => import('./PapTwoCompaniesExample.js'), "Replay two companies working together: Ledgerly is a company to Ada's agent and her personal agent at Northwind Bank; every approval is an Operation."),
147
- makeEntry('PapAccountTokensExample', () => import('./PapAccountTokensExample.js'), 'Replay Account Token refresh, rotation, narrowing, re-consent and revocation, with the token kept behind a host reference.'),
147
+ makeEntry('PapAccountTokensExample', () => import('./PapAccountTokensExample.js'), 'Replay refresh, rotation, narrowing, re-consent and revocation, with the token kept behind a host reference.'),
148
148
  makeEntry('PapMediatedSignInExample', () => import('./PapMediatedSignInExample.js'), "Replay Mediated Sign-In: credentials and a one-time code on the host's protected input, sent once to the company's own endpoint."),
149
149
  makeEntry('PapConversationStreamingExample', () => import('./PapConversationStreamingExample.js'), 'Replay a PAP conversation over SSE: display-only text deltas, complete events, and a Last-Event-ID resume.'),
150
150
  makeEntry('PapConversationControlExample', () => import('./PapConversationControlExample.js'), 'Replay conversation control: a Direct Conversation, a handoff to a person, and closing.'),
151
- makeEntry('PapOperationsExample', () => import('./PapOperationsExample.js'), 'Replay PAP Operations v1: exact approval of one revision, terms changed, at-most-once confirmation, and cancellation.'),
151
+ makeEntry('PapOperationsExample', () => import('./PapOperationsExample.js'), 'Replay PAP Operations version 2: the person asked about every revision, new terms asked again, performed at most once.'),
152
152
  makeEntry('PapSignInDisplayExample', () => import('./PapSignInDisplayExample.js'), 'The sign-in card as a display: a PapSignIn tool result drawn with resolveToolResult and ReactorDisplay, its link and code never in the model view.'),
153
153
  makeEntry('AgentNotificationsExample', () => import('./AgentNotificationsExample.js'), 'Notifications and event routing example.'),
154
154
  makeEntry('AgentOutputsExample', () => import('./AgentOutputsExample.js'), 'Structured outputs and rendering patterns.'),
@@ -32,7 +32,7 @@ export { default as ProtocolUcpCheckoutExample } from './ProtocolUcpCheckoutExam
32
32
  export { default as PapCompanyDiscoveryExample } from './PapCompanyDiscoveryExample';
33
33
  export { default as PapAgentIdentityExample } from './PapAgentIdentityExample';
34
34
  export { default as PapAuthorizationBoundaryExample } from './PapAuthorizationBoundaryExample';
35
- export { default as PapDpopProofExample } from './PapDpopProofExample';
35
+ export { default as PapSessionJwtExample } from './PapSessionJwtExample';
36
36
  export { default as PapSessionLifecycleExample } from './PapSessionLifecycleExample';
37
37
  export { default as PapGuidedJourneyExample } from './PapGuidedJourneyExample';
38
38
  export { default as PapUserWithACompanyExample } from './PapUserWithACompanyExample';
@@ -38,7 +38,7 @@ export { default as ProtocolUcpCheckoutExample } from './ProtocolUcpCheckoutExam
38
38
  export { default as PapCompanyDiscoveryExample } from './PapCompanyDiscoveryExample.js';
39
39
  export { default as PapAgentIdentityExample } from './PapAgentIdentityExample.js';
40
40
  export { default as PapAuthorizationBoundaryExample } from './PapAuthorizationBoundaryExample.js';
41
- export { default as PapDpopProofExample } from './PapDpopProofExample.js';
41
+ export { default as PapSessionJwtExample } from './PapSessionJwtExample.js';
42
42
  export { default as PapSessionLifecycleExample } from './PapSessionLifecycleExample.js';
43
43
  export { default as PapGuidedJourneyExample } from './PapGuidedJourneyExample.js';
44
44
  export { default as PapUserWithACompanyExample } from './PapUserWithACompanyExample.js';
@@ -84,7 +84,7 @@ const ANONYMOUS_EXAMPLES = new Set([
84
84
  'PapCompanyDiscoveryExample',
85
85
  'PapAgentIdentityExample',
86
86
  'PapAuthorizationBoundaryExample',
87
- 'PapDpopProofExample',
87
+ 'PapSessionJwtExample',
88
88
  'PapSessionLifecycleExample',
89
89
  'PapGuidedJourneyExample',
90
90
  // Replays of redacted traces the PAP Python demo worlds generate: static
@@ -1,4 +1,4 @@
1
- /** PAP Account Tokens: a redacted trace replayed step by step (see `traces/account-tokens.json`). */
1
+ /** PAP refresh tokens: a redacted trace replayed step by step (see `traces/account-tokens.json`). */
2
2
  import React from 'react';
3
3
  declare const PapAccountTokensView: React.FC;
4
4
  export default PapAccountTokensView;
@@ -6,7 +6,7 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
6
6
  import { useState } from 'react';
7
7
  import { Box } from '@datalayer/primer-addons';
8
8
  import { Button, Text } from '@primer/react';
9
- import { InMemorySessionKeys, JoseDpopProofProvider, buildDirectSignInRequest, buildSessionAssertionClaims, generatePairwiseUserId, } from '@datalayer/personal-agent-protocol';
9
+ import { buildClientAssertionClaims, buildDirectSignInRequest, generatePairwiseUserId, newSessionId, } from '@datalayer/personal-agent-protocol';
10
10
  import { PapExamplePage, PapResult } from './PapExamplePage.js';
11
11
  /** Generate real security material and reveal only its non-secret policy. */
12
12
  const PapAuthorizationBoundaryView = () => {
@@ -16,45 +16,38 @@ const PapAuthorizationBoundaryView = () => {
16
16
  setError(null);
17
17
  try {
18
18
  const clientId = 'https://assistant.example/agent.json';
19
- // PAP §4.2: the assertion names the company's issuer, not its token endpoint.
19
+ // The assertion names the company's issuer, not its token endpoint.
20
20
  const issuer = 'https://shop.example';
21
- // Draft 0.3 §4.3: the Session has its own DPoP key, the Session Key; the
22
- // Direct Sign-In code is bound to its thumbprint (`dpop_jkt`).
23
- const proofs = new JoseDpopProofProvider({
24
- keys: new InMemorySessionKeys(),
25
- });
26
- const sessionKey = await proofs.newSessionKey({
27
- tenantId: 'example-tenant',
28
- issuer,
29
- });
30
- const claims = buildSessionAssertionClaims({
31
- clientId,
32
- pairwiseUserId: generatePairwiseUserId(),
33
- issuer,
34
- });
21
+ const claims = buildClientAssertionClaims({ clientId, issuer });
22
+ // A Session is local: a random `sid` for a pairwise User ID, no request.
23
+ const sid = newSessionId();
24
+ const sub = generatePairwiseUserId();
35
25
  const request = await buildDirectSignInRequest({
36
26
  authorizationEndpoint: 'https://shop.example/oauth/authorize',
37
27
  issuer: 'https://shop.example',
38
28
  clientId,
39
29
  redirectUri: 'https://assistant.example/callback',
40
30
  scopes: ['orders:read', 'orders:write'],
41
- sessionKey,
42
31
  });
32
+ const authorization = new URL(request.authorizationUrl.reveal());
43
33
  setSummary({
44
34
  session: {
35
+ chosenHere: sid.length >= 22,
36
+ pairwise: sub !== sid,
37
+ sidWithheld: true,
38
+ pairwiseSubjectWithheld: true,
39
+ },
40
+ clientAssertion: {
45
41
  issuerBoundToClient: claims.iss === clientId,
46
42
  audienceBoundToIssuer: claims.aud === issuer,
47
43
  lifetimeSeconds: claims.exp - claims.iat,
48
- pairwiseSubjectWithheld: true,
49
44
  uniqueRequestIdWithheld: true,
50
45
  unsignedAssertionWithheld: true,
51
46
  },
52
47
  directSignIn: {
53
48
  requestedScopes: request.scopes,
54
49
  pkceMethod: 'S256',
55
- codeBoundToSessionKey: request.sessionKey === sessionKey &&
56
- new URL(request.authorizationUrl.reveal()).searchParams.get('dpop_jkt') === sessionKey,
57
- sessionKeyWithheld: true,
50
+ namesNoSession: !authorization.searchParams.has('sid'),
58
51
  randomState: true,
59
52
  userOwnedBrowserRequired: true,
60
53
  authorizationUrlWithheld: true,
@@ -68,6 +61,6 @@ const PapAuthorizationBoundaryView = () => {
68
61
  setError(cause instanceof Error ? cause.message : String(cause));
69
62
  }
70
63
  };
71
- return (_jsxs(PapExamplePage, { eyebrow: "PAP \u00B7 Authorization boundary", title: "Generate secrets in the host; return policy to the agent", description: "This example creates a real pairwise identity, a Session Key (the Session's own DPoP key, PAP draft 0.3), unique assertion ID, OAuth state and S256 PKCE verifier, the code bound to the Session Key. None crosses the Reactor view boundary. Studio hands the authorization URL directly to a user-owned browser and stores tokens behind opaque references.", children: [_jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 3, p: 3, border: "1px solid", borderColor: "border.default", borderRadius: 2, bg: "canvas.default", children: [_jsx(Text, { sx: { color: 'fg.muted' }, children: "Generate a fresh Session and Direct Sign-In request inside this host." }), _jsx(Button, { variant: "primary", onClick: () => void generate(), children: "Generate safely" })] }), error ? _jsx(Text, { sx: { color: 'danger.fg' }, children: error }) : null, summary ? (_jsx(PapResult, { title: "Model-safe boundary result", value: summary })) : null] }));
64
+ return (_jsxs(PapExamplePage, { eyebrow: "PAP \u00B7 Authorization boundary", title: "Generate secrets in the host; return policy to the agent", description: "This example creates a real pairwise identity, a random Session ID, a unique assertion ID, OAuth state and an S256 PKCE verifier. Sign-in is plain OAuth and names no Session. None crosses the Reactor view boundary. Studio hands the authorization URL directly to a user-owned browser and stores tokens behind opaque references.", children: [_jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 3, p: 3, border: "1px solid", borderColor: "border.default", borderRadius: 2, bg: "canvas.default", children: [_jsx(Text, { sx: { color: 'fg.muted' }, children: "Generate a fresh Session and Direct Sign-In request inside this host." }), _jsx(Button, { variant: "primary", onClick: () => void generate(), children: "Generate safely" })] }), error ? _jsx(Text, { sx: { color: 'danger.fg' }, children: error }) : null, summary ? (_jsx(PapResult, { title: "Model-safe boundary result", value: summary })) : null] }));
72
65
  };
73
66
  export default PapAuthorizationBoundaryView;
@@ -8,7 +8,7 @@ import { Box } from '@datalayer/primer-addons';
8
8
  import { contribution, definePlugin } from '@datalayer/reactor';
9
9
  import { Button, Heading, IconButton, Label, Text } from '@primer/react';
10
10
  import { ChevronLeftIcon, ChevronRightIcon } from '@primer/octicons-react';
11
- import { ConversationClient, DpopFetchClient, DpopProofProviders, InMemorySessionKeys, JoseDpopProofProvider, SecretValue, buildPapReactor, buildDirectSignInRequest, buildSessionAssertionClaims, parseDiscoveryDocument, parseOAuthServerMetadata, } from '@datalayer/personal-agent-protocol';
11
+ import { ConversationClient, DelegatedSessionSigner, InMemoryDelegatedKeys, SecretValue, SessionClient, SessionFetchClient, SessionSigners, buildPapReactor, buildDirectSignInRequest, parseDiscoveryDocument, parseOAuthServerMetadata, } from '@datalayer/personal-agent-protocol';
12
12
  import { ChatMessageList } from '../../chat/messages/ChatMessageList.js';
13
13
  import { PapExamplePage } from './PapExamplePage.js';
14
14
  const conversationStart = [
@@ -52,7 +52,7 @@ const STEPS = [
52
52
  },
53
53
  {
54
54
  title: 'Starting signed out',
55
- summary: 'Atlas opens a Session under a key of its own, the Session Key, and can ask about the return before knowing who the user is. Northstar answers insufficient_scope: order access needs sign-in.',
55
+ summary: 'Atlas chooses a random Session ID, with no request, and can ask about the return before knowing who the user is. Northstar answers insufficient_scope: order access needs sign-in.',
56
56
  channel: 'Session + conversation',
57
57
  messages: [
58
58
  ...conversationStart,
@@ -63,25 +63,33 @@ const STEPS = [
63
63
  ],
64
64
  facts: [
65
65
  { label: 'Personal agent', value: 'Atlas' },
66
- { label: 'Session', value: 'Signed out · its own key' },
66
+ { label: 'Session', value: 'Signed out · a Session JWT per request' },
67
67
  { label: 'Conversation', value: 'Waiting for sign-in' },
68
68
  ],
69
69
  method: 'POST',
70
- target: 'https://auth.northstar.example/oauth/token',
71
- detailLabel: 'Atlas → authorization server',
72
- request: `Content-Type: application/x-www-form-urlencoded
73
- DPoP: [fresh proof, signed with the new Session Key]
70
+ target: 'https://api.northstar.example/poppy/conversations',
71
+ detailLabel: 'Atlas → company agent',
72
+ request: `Poppy-Session: [fresh JWT, naming the sid, signed with a delegated key]
73
+ Content-Type: application/json
74
74
 
75
- grant_type=urn:ietf:params:oauth:grant-type:jwt-bearer
76
- assertion=[host-only session assertion]
77
- client_assertion=[host-only client assertion]`,
78
- response: `200 OK
79
75
  {
80
- "access_token": "[stored by host]",
81
- "token_type": "DPoP",
82
- "expires_in": 300
83
- }
84
- (the Session is named by its key's thumbprint; the grant says signed out)`,
76
+ "message": {
77
+ "id": "msg_return",
78
+ "author": { "type": "agent" },
79
+ "text": "The user wants to return a jacket."
80
+ }
81
+ }`,
82
+ response: `201 Created
83
+ {
84
+ "conversation_id": "cnv_return",
85
+ "events": [{
86
+ "type": "authorization",
87
+ "error": "insufficient_scope",
88
+ "scope": "orders:read orders:return"
89
+ }],
90
+ "status": "idle",
91
+ "responder": "agent"
92
+ }`,
85
93
  },
86
94
  {
87
95
  title: 'The user signs in',
@@ -102,8 +110,7 @@ client_id=https://atlas.example/agent.json
102
110
  redirect_uri=https://atlas.example/oauth/callback
103
111
  scope=orders:read orders:return
104
112
  state=[single-use, host-only]
105
- code_challenge=[S256, host-only verifier]
106
- dpop_jkt=[the Session Key's thumbprint]`,
113
+ code_challenge=[S256, host-only verifier]`,
107
114
  response: `302 Found
108
115
  Location: https://atlas.example/oauth/callback
109
116
  ?code=[single-use authorization code]
@@ -131,8 +138,8 @@ Location: https://atlas.example/oauth/callback
131
138
  method: 'POST',
132
139
  target: 'https://api.northstar.example/poppy/conversations/cnv_return/messages',
133
140
  detailLabel: 'Atlas ↔ company agent',
134
- request: `Authorization: DPoP [host-only Session Token]
135
- DPoP: [fresh proof]
141
+ request: `Authorization: Bearer [host-only access token]
142
+ Poppy-Session: [fresh JWT]
136
143
  Content-Type: application/json
137
144
 
138
145
  {
@@ -182,8 +189,8 @@ Content-Type: application/json
182
189
  method: 'POST',
183
190
  target: 'https://api.northstar.example/poppy/conversations/cnv_return/messages',
184
191
  detailLabel: 'Atlas ↔ company agent',
185
- request: `Authorization: DPoP [host-only Session Token]
186
- DPoP: [fresh proof]
192
+ request: `Authorization: Bearer [host-only access token]
193
+ Poppy-Session: [fresh JWT]
187
194
  Content-Type: application/json
188
195
 
189
196
  {
@@ -227,7 +234,7 @@ const companyReply = (response) => {
227
234
  *
228
235
  * The company side is deliberately an in-page deterministic simulator: this
229
236
  * makes the example runnable without an account while ensuring that requests,
230
- * proof-bound transport, response parsing, and messages all use the real SDK.
237
+ * the Session header, response parsing, and messages all use the real SDK.
231
238
  */
232
239
  const runJourney = async () => {
233
240
  parseDiscoveryDocument({
@@ -255,32 +262,16 @@ const runJourney = async () => {
255
262
  token_endpoint: 'https://auth.northstar.example/oauth/token',
256
263
  revocation_endpoint: 'https://auth.northstar.example/oauth/revoke',
257
264
  authorization_endpoint: 'https://auth.northstar.example/oauth/authorize',
258
- grant_types_supported: [
259
- 'urn:ietf:params:oauth:grant-type:jwt-bearer',
260
- 'refresh_token',
261
- 'authorization_code',
262
- ],
265
+ grant_types_supported: ['refresh_token', 'authorization_code'],
263
266
  protected_resources: ['https://northstar.example'],
264
267
  scopes_supported: ['orders:read', 'orders:return'],
265
268
  });
266
- // The Session's own DPoP key, its thumbprint the Session's name (§4.3).
267
- const proofs = new JoseDpopProofProvider({ keys: new InMemorySessionKeys() });
268
- const sessionKey = await proofs.newSessionKey({
269
- tenantId: 'guided-example',
270
- issuer: 'https://auth.northstar.example',
271
- });
272
- buildSessionAssertionClaims({
273
- clientId: 'https://atlas.example/agent.json',
274
- pairwiseUserId: 'usr_host_only_journey',
275
- issuer: 'https://auth.northstar.example',
276
- });
277
269
  await buildDirectSignInRequest({
278
270
  authorizationEndpoint: 'https://auth.northstar.example/oauth/authorize',
279
271
  issuer: 'https://auth.northstar.example',
280
272
  clientId: 'https://atlas.example/agent.json',
281
273
  redirectUri: 'https://atlas.example/oauth/callback',
282
274
  scopes: ['orders:read', 'orders:return'],
283
- sessionKey,
284
275
  });
285
276
  const replies = [
286
277
  'I can help with that. Please sign in so I can find the order.',
@@ -326,34 +317,44 @@ const runJourney = async () => {
326
317
  const securityPlugin = definePlugin({
327
318
  name: '@datalayer/loop-example-pap-guided-security',
328
319
  contributes: [
329
- contribution(DpopProofProviders, {
330
- newSessionKey: options => proofs.newSessionKey(options),
331
- discardSessionKey: options => proofs.discardSessionKey(options),
332
- create: request => proofs.create(request),
333
- }, { id: 'guided-example-dpop' }),
320
+ contribution(SessionSigners,
321
+ // A real delegated key; the delegation's signature is a stand-in for a
322
+ // key in the agent's `jwks_uri`.
323
+ new DelegatedSessionSigner({
324
+ custody: new InMemoryDelegatedKeys(),
325
+ signer: {
326
+ sign: async (_claims, options) => new SecretValue(`host-only-${options.purpose}`),
327
+ },
328
+ }), { id: 'guided-example-session-signer' }),
334
329
  ],
335
330
  });
336
331
  const reactor = buildPapReactor({ fetch: localCompanyFetch }, [
337
332
  securityPlugin,
338
333
  ]);
339
334
  try {
340
- const transport = new DpopFetchClient({
335
+ const transport = new SessionFetchClient({
341
336
  reactor,
342
337
  fetch: localCompanyFetch,
343
338
  });
344
339
  const conversations = new ConversationClient({ reactor, transport });
345
- const session = (signedIn) => ({
346
- accessToken: new SecretValue(signedIn ? 'host-only-signed-in-token' : 'host-only-session-token'),
347
- tokenType: 'DPoP',
348
- expiresIn: 300,
349
- scopes: signedIn ? ['orders:read', 'orders:return'] : [],
350
- sessionKey,
351
- signedIn,
352
- });
353
- const requestOptions = (token) => ({
354
- token,
355
- tenantId: 'guided-example',
340
+ const session = await new SessionClient({
341
+ reactor,
342
+ fetch: localCompanyFetch,
343
+ }).start({
344
+ clientId: 'https://atlas.example/agent.json',
345
+ pairwiseUserId: 'usr_host_only_journey',
356
346
  issuer: 'https://auth.northstar.example',
347
+ tenantId: 'guided-example',
348
+ });
349
+ const token = {
350
+ accessToken: new SecretValue('host-only-access-token'),
351
+ tokenType: 'Bearer',
352
+ expiresIn: 300,
353
+ scopes: ['orders:read', 'orders:return'],
354
+ };
355
+ const requestOptions = (signedIn) => ({
356
+ session,
357
+ ...(signedIn ? { token } : {}),
357
358
  wait: 0,
358
359
  });
359
360
  const endpoint = 'https://api.northstar.example/poppy/conversations';
@@ -361,18 +362,18 @@ const runJourney = async () => {
361
362
  id: conversations.generateMessageId(),
362
363
  author: { type: 'agent' },
363
364
  text: conversationStart[0]?.text,
364
- }, requestOptions(session(false)));
365
+ }, requestOptions(false));
365
366
  const signInReply = companyReply(started);
366
367
  const offer = companyReply(await conversations.send(endpoint, 'cnv_return', {
367
368
  id: conversations.generateMessageId(),
368
369
  author: { type: 'agent' },
369
370
  text: 'The user has signed in. Continue the return request.',
370
- }, requestOptions(session(true))));
371
+ }, requestOptions(true)));
371
372
  const confirmation = companyReply(await conversations.send(endpoint, 'cnv_return', {
372
373
  id: conversations.generateMessageId(),
373
374
  author: { type: 'agent' },
374
375
  text: 'The user chose the even exchange.',
375
- }, requestOptions(session(true))));
376
+ }, requestOptions(true)));
376
377
  const signedInMessages = [
377
378
  ...conversationStart,
378
379
  { speaker: 'company', text: signInReply },
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ /** Create real Session JWTs while retaining only non-secret evidence. */
3
+ declare const PapSessionJwtView: React.FC;
4
+ export default PapSessionJwtView;
@@ -0,0 +1,69 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /*
3
+ * Copyright (c) 2025-2026 Datalayer, Inc.
4
+ * Distributed under the terms of the Modified BSD License.
5
+ */
6
+ import { useState } from 'react';
7
+ import { Box } from '@datalayer/primer-addons';
8
+ import { Button, Text } from '@primer/react';
9
+ import { DelegatedSessionSigner, InMemoryDelegatedKeys, SecretValue, newSessionId, } from '@datalayer/personal-agent-protocol';
10
+ import { PapExamplePage, PapResult } from './PapExamplePage.js';
11
+ /** One part of a compact JWT, read here because nothing verifies it in this view. */
12
+ const part = (jwt, index) => JSON.parse(atob((jwt.split('.')[index] ?? '').replace(/-/g, '+').replace(/_/g, '/')));
13
+ /** Create real Session JWTs while retaining only non-secret evidence. */
14
+ const PapSessionJwtView = () => {
15
+ const [summary, setSummary] = useState(null);
16
+ const [error, setError] = useState(null);
17
+ const createJwts = async () => {
18
+ setError(null);
19
+ try {
20
+ // A delegated P-256 key per User ID, kept in this host. A key from the
21
+ // agent's `jwks_uri` signs each delegation; here a stand-in does, and the
22
+ // company's verification is the server's half.
23
+ const signer = new DelegatedSessionSigner({
24
+ custody: new InMemoryDelegatedKeys(),
25
+ signer: {
26
+ sign: async (_claims, options) => new SecretValue(`host-only-${options.purpose}`),
27
+ },
28
+ });
29
+ const request = {
30
+ method: 'POST',
31
+ url: 'https://api.company.example/orders?draft=true#editor',
32
+ tenantId: 'example-tenant',
33
+ issuer: 'https://company.example',
34
+ clientId: 'https://assistant.example/agent.json',
35
+ sid: newSessionId(),
36
+ sub: 'usr_host_only_example',
37
+ accessToken: new SecretValue('host-only-example-token'),
38
+ };
39
+ const first = await signer.sign(request);
40
+ const second = await signer.sign(request);
41
+ const other = await signer.sign({
42
+ ...request,
43
+ sub: 'usr_host_only_other',
44
+ });
45
+ const header = part(first.reveal(), 0);
46
+ const claims = part(first.reveal(), 1);
47
+ setSummary({
48
+ algorithm: header.alg,
49
+ type: header.typ,
50
+ freshJwtPerRequest: first.reveal() !== second.reveal(),
51
+ methodBound: claims.htm === 'POST',
52
+ urlBoundWithoutQueryOrFragment: claims.htu === 'https://api.company.example/orders',
53
+ accessTokenBound: typeof claims.ath === 'string',
54
+ namesItsSession: claims.sid === request.sid,
55
+ carriesItsDelegation: typeof header.pap_dlg === 'string',
56
+ oneKeyPerUserId: header.kid !== part(other.reveal(), 0).kid,
57
+ jwtRedactedByDefault: first.toJSON() === '[REDACTED]',
58
+ jwtWithheldFromUiState: true,
59
+ keyMaterialWithheldFromUiState: true,
60
+ });
61
+ }
62
+ catch (cause) {
63
+ setSummary(null);
64
+ setError(cause instanceof Error ? cause.message : String(cause));
65
+ }
66
+ };
67
+ return (_jsxs(PapExamplePage, { eyebrow: "PAP \u00B7 Session JWT", title: "Create a fresh Session JWT for every request", description: "This Reactor view creates a non-exportable delegated P-256 key and real Poppy-Session JWTs in the browser host. Only policy evidence enters React state; JWTs, tokens, identifiers and key material stay outside the agent and rendered UI. Server-side verification adds the delegation, signature, request, token and replay checks.", children: [_jsxs(Box, { display: "flex", alignItems: "center", justifyContent: "space-between", gap: 3, p: 3, border: "1px solid", borderColor: "border.default", borderRadius: 2, bg: "canvas.default", children: [_jsx(Text, { sx: { color: 'fg.muted' }, children: "Generate two Session JWTs for the same request without retaining either." }), _jsx(Button, { variant: "primary", onClick: () => void createJwts(), children: "Create safely" })] }), error ? _jsx(Text, { sx: { color: 'danger.fg' }, children: error }) : null, summary ? (_jsx(PapResult, { title: "Safe Session JWT evidence", value: summary })) : null] }));
68
+ };
69
+ export default PapSessionJwtView;