@adonis-agora/agent 0.93.0 → 0.95.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 +20 -0
- package/dist/assets/spa/assets/{index-DUq09Q_k.js → index-DBu17cDY.js} +1 -1
- package/dist/assets/spa/index.html +1 -1
- package/dist/providers/agent_provider.d.ts.map +1 -1
- package/dist/providers/agent_provider.js +20 -2
- package/dist/providers/agent_provider.js.map +1 -1
- package/dist/providers/poppy_connections_provider.d.ts +1 -1
- package/dist/providers/poppy_connections_provider.js +1 -1
- package/dist/providers/poppy_provider.d.ts +1 -1
- package/dist/providers/poppy_provider.d.ts.map +1 -1
- package/dist/providers/poppy_provider.js +6 -6
- package/dist/providers/poppy_provider.js.map +1 -1
- package/dist/src/agent-service.d.ts +11 -1
- package/dist/src/agent-service.d.ts.map +1 -1
- package/dist/src/agent-service.js +13 -4
- package/dist/src/agent-service.js.map +1 -1
- package/dist/src/diagnostics.d.ts +2 -0
- package/dist/src/diagnostics.d.ts.map +1 -1
- package/dist/src/diagnostics.js.map +1 -1
- package/dist/src/index.d.ts +1 -1
- package/dist/src/index.js +1 -1
- package/dist/src/mcp/auth.d.ts +3 -3
- package/dist/src/mcp/auth.d.ts.map +1 -1
- package/dist/src/mcp/auth.js +2 -29
- package/dist/src/mcp/auth.js.map +1 -1
- package/dist/src/mcp/discovery.d.ts +3 -3
- package/dist/src/mcp/discovery.d.ts.map +1 -1
- package/dist/src/mcp/discovery.js +2 -2
- package/dist/src/poppy/auth.d.ts +20 -16
- package/dist/src/poppy/auth.d.ts.map +1 -1
- package/dist/src/poppy/auth.js.map +1 -1
- package/dist/src/poppy/conversations.d.ts +25 -25
- package/dist/src/poppy/conversations.d.ts.map +1 -1
- package/dist/src/poppy/conversations.js +37 -37
- package/dist/src/poppy/conversations.js.map +1 -1
- package/dist/src/poppy/define_config.d.ts +7 -7
- package/dist/src/poppy/define_config.d.ts.map +1 -1
- package/dist/src/poppy/define_config.js +1 -1
- package/dist/src/poppy/endpoints.d.ts +2 -2
- package/dist/src/poppy/endpoints.js +1 -1
- package/dist/src/poppy/handler.d.ts +5 -5
- package/dist/src/poppy/handler.d.ts.map +1 -1
- package/dist/src/poppy/handler.js +23 -21
- package/dist/src/poppy/handler.js.map +1 -1
- package/dist/src/poppy/index.d.ts +2 -2
- package/dist/src/poppy/index.d.ts.map +1 -1
- package/dist/src/poppy/index.js +1 -1
- package/dist/src/poppy/index.js.map +1 -1
- package/dist/src/poppy/protocol.d.ts +30 -23
- package/dist/src/poppy/protocol.d.ts.map +1 -1
- package/dist/src/poppy/protocol.js +16 -17
- package/dist/src/poppy/protocol.js.map +1 -1
- package/dist/src/poppy/redis-store.d.ts +1 -1
- package/dist/src/poppy/redis-store.js +1 -1
- package/dist/src/poppy/store.d.ts +7 -7
- package/dist/src/poppy/store.js +1 -1
- package/dist/src/poppy-client/api.d.ts +5 -4
- package/dist/src/poppy-client/api.d.ts.map +1 -1
- package/dist/src/poppy-client/api.js +14 -9
- package/dist/src/poppy-client/api.js.map +1 -1
- package/dist/src/poppy-client/browser.d.ts +12 -18
- package/dist/src/poppy-client/browser.d.ts.map +1 -1
- package/dist/src/poppy-client/browser.js +33 -73
- package/dist/src/poppy-client/browser.js.map +1 -1
- package/dist/src/poppy-client/cli/main.d.ts.map +1 -1
- package/dist/src/poppy-client/cli/main.js +48 -56
- package/dist/src/poppy-client/cli/main.js.map +1 -1
- package/dist/src/poppy-client/company.d.ts +43 -28
- package/dist/src/poppy-client/company.d.ts.map +1 -1
- package/dist/src/poppy-client/company.js +216 -160
- package/dist/src/poppy-client/company.js.map +1 -1
- package/dist/src/poppy-client/conversations.d.ts +12 -13
- package/dist/src/poppy-client/conversations.d.ts.map +1 -1
- package/dist/src/poppy-client/conversations.js +24 -22
- package/dist/src/poppy-client/conversations.js.map +1 -1
- package/dist/src/poppy-client/discovery.d.ts +32 -10
- package/dist/src/poppy-client/discovery.d.ts.map +1 -1
- package/dist/src/poppy-client/discovery.js +134 -68
- package/dist/src/poppy-client/discovery.js.map +1 -1
- package/dist/src/poppy-client/dpop.d.ts +2 -1
- package/dist/src/poppy-client/dpop.d.ts.map +1 -1
- package/dist/src/poppy-client/dpop.js +2 -1
- package/dist/src/poppy-client/dpop.js.map +1 -1
- package/dist/src/poppy-client/errors.d.ts +5 -4
- package/dist/src/poppy-client/errors.d.ts.map +1 -1
- package/dist/src/poppy-client/errors.js +5 -4
- package/dist/src/poppy-client/errors.js.map +1 -1
- package/dist/src/poppy-client/http.d.ts +4 -2
- package/dist/src/poppy-client/http.d.ts.map +1 -1
- package/dist/src/poppy-client/http.js +9 -5
- package/dist/src/poppy-client/http.js.map +1 -1
- package/dist/src/poppy-client/identity.d.ts +15 -15
- package/dist/src/poppy-client/identity.d.ts.map +1 -1
- package/dist/src/poppy-client/identity.js +17 -33
- package/dist/src/poppy-client/identity.js.map +1 -1
- package/dist/src/poppy-client/index.d.ts +6 -3
- package/dist/src/poppy-client/index.d.ts.map +1 -1
- package/dist/src/poppy-client/index.js +6 -3
- package/dist/src/poppy-client/index.js.map +1 -1
- package/dist/src/poppy-client/llm.js +4 -4
- package/dist/src/poppy-client/llm.js.map +1 -1
- package/dist/src/poppy-client/mcp.d.ts +3 -4
- package/dist/src/poppy-client/mcp.d.ts.map +1 -1
- package/dist/src/poppy-client/mcp.js +26 -38
- package/dist/src/poppy-client/mcp.js.map +1 -1
- package/dist/src/poppy-client/safe_fetch.d.ts +30 -0
- package/dist/src/poppy-client/safe_fetch.d.ts.map +1 -0
- package/dist/src/poppy-client/safe_fetch.js +210 -0
- package/dist/src/poppy-client/safe_fetch.js.map +1 -0
- package/dist/src/poppy-client/session_jwt.d.ts +20 -0
- package/dist/src/poppy-client/session_jwt.d.ts.map +1 -0
- package/dist/src/poppy-client/session_jwt.js +37 -0
- package/dist/src/poppy-client/session_jwt.js.map +1 -0
- package/dist/src/poppy-client/signin.d.ts +34 -11
- package/dist/src/poppy-client/signin.d.ts.map +1 -1
- package/dist/src/poppy-client/signin.js +134 -80
- package/dist/src/poppy-client/signin.js.map +1 -1
- package/dist/src/poppy-client/store.d.ts +23 -11
- package/dist/src/poppy-client/store.d.ts.map +1 -1
- package/dist/src/poppy-client/store.js +1 -1
- package/dist/src/poppy-client/store.js.map +1 -1
- package/dist/src/poppy-client/task_coverage.d.ts +13 -0
- package/dist/src/poppy-client/task_coverage.d.ts.map +1 -0
- package/dist/src/poppy-client/task_coverage.js +66 -0
- package/dist/src/poppy-client/task_coverage.js.map +1 -0
- package/dist/src/poppy-client/token_client.d.ts +36 -33
- package/dist/src/poppy-client/token_client.d.ts.map +1 -1
- package/dist/src/poppy-client/token_client.js +47 -47
- package/dist/src/poppy-client/token_client.js.map +1 -1
- package/dist/src/poppy-client/types.d.ts +81 -42
- package/dist/src/poppy-client/types.d.ts.map +1 -1
- package/dist/src/poppy-client/types.js +1 -1
- package/dist/src/poppy-client/util.d.ts +12 -3
- package/dist/src/poppy-client/util.d.ts.map +1 -1
- package/dist/src/poppy-client/util.js +29 -9
- package/dist/src/poppy-client/util.js.map +1 -1
- package/dist/src/poppy-connections/config.d.ts +2 -2
- package/dist/src/poppy-connections/config.js +1 -1
- package/dist/src/poppy-connections/config.js.map +1 -1
- package/dist/src/poppy-connections/crypto.d.ts +2 -2
- package/dist/src/poppy-connections/crypto.js +2 -2
- package/dist/src/poppy-connections/index.d.ts +1 -1
- package/dist/src/poppy-connections/index.js +1 -1
- package/dist/src/poppy-connections/service.d.ts +11 -10
- package/dist/src/poppy-connections/service.d.ts.map +1 -1
- package/dist/src/poppy-connections/service.js +33 -21
- package/dist/src/poppy-connections/service.js.map +1 -1
- package/dist/src/poppy-connections/store.d.ts +2 -2
- package/dist/src/poppy-connections/tools.d.ts.map +1 -1
- package/dist/src/poppy-connections/tools.js +5 -4
- package/dist/src/poppy-connections/tools.js.map +1 -1
- package/dist/src/spi/agent-store.d.ts +6 -0
- package/dist/src/spi/agent-store.d.ts.map +1 -1
- package/dist/src/spi/agent-store.js.map +1 -1
- package/dist/src/spi/governance-queries.d.ts +23 -1
- package/dist/src/spi/governance-queries.d.ts.map +1 -1
- package/dist/src/spi/governance-queries.js +16 -1
- package/dist/src/spi/governance-queries.js.map +1 -1
- package/dist/src/stores/lucid-governance-queries.d.ts +2 -2
- package/dist/src/stores/lucid-governance-queries.d.ts.map +1 -1
- package/dist/src/stores/lucid-governance-queries.js +11 -7
- package/dist/src/stores/lucid-governance-queries.js.map +1 -1
- package/dist/src/stores/lucid-schema.d.ts +2 -0
- package/dist/src/stores/lucid-schema.d.ts.map +1 -1
- package/dist/src/stores/lucid-schema.js +12 -0
- package/dist/src/stores/lucid-schema.js.map +1 -1
- package/dist/src/stores/lucid.d.ts +7 -0
- package/dist/src/stores/lucid.d.ts.map +1 -1
- package/dist/src/stores/lucid.js +21 -3
- package/dist/src/stores/lucid.js.map +1 -1
- package/dist/src/testing/in-memory-governance-queries.d.ts +2 -2
- package/dist/src/testing/in-memory-governance-queries.d.ts.map +1 -1
- package/dist/src/testing/in-memory-governance-queries.js +11 -2
- package/dist/src/testing/in-memory-governance-queries.js.map +1 -1
- package/dist/src/testing/in-memory-store.d.ts +2 -0
- package/dist/src/testing/in-memory-store.d.ts.map +1 -1
- package/dist/src/testing/in-memory-store.js +7 -2
- package/dist/src/testing/in-memory-store.js.map +1 -1
- package/dist/src/usage-ledger.d.ts.map +1 -1
- package/dist/src/usage-ledger.js +1 -0
- package/dist/src/usage-ledger.js.map +1 -1
- package/package.json +6 -6
- package/skills/agent-governance/SKILL.md +3 -3
- package/skills/agent-tools/SKILL.md +3 -3
|
@@ -1,48 +1,54 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* The wire format of Personal Agent Protocol ("Poppy", Draft 0.
|
|
3
|
-
* events, statuses and the error codes of §
|
|
2
|
+
* The wire format of Personal Agent Protocol ("Poppy", Draft 0.3, §7) conversations: messages,
|
|
3
|
+
* events, statuses and the error codes of §8.13. Hand-rolled like the A2A surface — the rules are
|
|
4
4
|
* few and exact, and unknown fields are ignored everywhere (§3.1, §3.3).
|
|
5
5
|
*
|
|
6
|
-
* @experimental Tracks Personal Agent Protocol Draft 0.
|
|
6
|
+
* @experimental Tracks Personal Agent Protocol Draft 0.3 (https://personalagentprotocol.org/docs/spec),
|
|
7
7
|
* a spec still in development: this API WILL change as the spec evolves — possibly in breaking
|
|
8
8
|
* ways, outside semver majors while it is a draft.
|
|
9
9
|
*/
|
|
10
10
|
/** The `protocol_version` this surface implements. */
|
|
11
|
-
export declare const POPPY_PROTOCOL_VERSION = "0.
|
|
12
|
-
/** The `type` of this surface's entry in `poppy.json` `agent.protocols` (§
|
|
11
|
+
export declare const POPPY_PROTOCOL_VERSION = "0.3";
|
|
12
|
+
/** The `type` of this surface's entry in `poppy.json` `agent.protocols` (§8.1). */
|
|
13
13
|
export declare const POPPY_PROTOCOL_TYPE = "poppy";
|
|
14
|
-
/** The account scopes the protocol defines (§4.4). Companies may add their own. */
|
|
15
|
-
export declare const POPPY_READ_SCOPE = "poppy:read";
|
|
16
|
-
export declare const POPPY_WRITE_SCOPE = "poppy:write";
|
|
17
14
|
export type PoppyStatus = 'working' | 'idle' | 'queued' | 'closed';
|
|
18
15
|
export type PoppyResponder = 'agent' | 'human';
|
|
19
|
-
export type
|
|
20
|
-
/**
|
|
16
|
+
export type PoppyAuthorType = 'agent' | 'human';
|
|
17
|
+
/** Who wrote a message (§8.4). Only Company messages have `id`, `name` and `image`. */
|
|
18
|
+
export interface PoppyAuthor {
|
|
19
|
+
type: PoppyAuthorType;
|
|
20
|
+
id?: string;
|
|
21
|
+
name?: string;
|
|
22
|
+
image?: string;
|
|
23
|
+
}
|
|
24
|
+
/** Facts about the User's situation (§8.4). Other fields are kept as sent. */
|
|
21
25
|
export interface PoppyContext {
|
|
22
26
|
locale?: string;
|
|
23
27
|
time_zone?: string;
|
|
24
28
|
user_available?: boolean;
|
|
25
29
|
[field: string]: unknown;
|
|
26
30
|
}
|
|
27
|
-
/** A message as the Personal Agent sends it (§
|
|
31
|
+
/** A message as the Personal Agent sends it (§8.4). */
|
|
28
32
|
export interface PoppyInboundMessage {
|
|
29
33
|
id: string;
|
|
30
|
-
|
|
34
|
+
author: {
|
|
35
|
+
type: PoppyAuthorType;
|
|
36
|
+
};
|
|
31
37
|
text?: string;
|
|
32
38
|
data?: Record<string, unknown>;
|
|
33
39
|
context?: PoppyContext;
|
|
34
40
|
}
|
|
35
|
-
/** A message as it appears in a `message` event (§
|
|
41
|
+
/** A message as it appears in a `message` event (§8.5): `role` says which side it came from. */
|
|
36
42
|
export interface PoppyEventMessage {
|
|
37
43
|
id: string;
|
|
38
44
|
role: 'user' | 'company';
|
|
39
|
-
|
|
45
|
+
author: PoppyAuthor;
|
|
40
46
|
text?: string;
|
|
41
47
|
data?: Record<string, unknown>;
|
|
42
48
|
context?: PoppyContext;
|
|
43
49
|
}
|
|
44
50
|
export type PoppyEventType = 'message' | 'state' | 'authorization' | 'user_requested' | 'direct_opened' | 'direct_closed';
|
|
45
|
-
/** One event of a conversation (§
|
|
51
|
+
/** One event of a conversation (§8.5): `id`, `type`, `created_at`, and the type's own fields. */
|
|
46
52
|
export interface PoppyEvent {
|
|
47
53
|
id: string;
|
|
48
54
|
type: PoppyEventType | (string & {});
|
|
@@ -59,8 +65,8 @@ export type PoppyEventBody = {
|
|
|
59
65
|
responder: PoppyResponder;
|
|
60
66
|
} | {
|
|
61
67
|
type: 'authorization';
|
|
62
|
-
error: '
|
|
63
|
-
scope
|
|
68
|
+
error: 'insufficient_scope';
|
|
69
|
+
scope: string;
|
|
64
70
|
} | {
|
|
65
71
|
type: 'user_requested';
|
|
66
72
|
reason: string;
|
|
@@ -68,7 +74,7 @@ export type PoppyEventBody = {
|
|
|
68
74
|
type: 'direct_opened' | 'direct_closed';
|
|
69
75
|
conversation_id: string;
|
|
70
76
|
};
|
|
71
|
-
/** The conversation errors of §
|
|
77
|
+
/** The conversation errors of §8.13, plus the request errors this surface answers. */
|
|
72
78
|
declare const ERRORS: {
|
|
73
79
|
readonly conversation_not_found: 404;
|
|
74
80
|
readonly conversation_closed: 409;
|
|
@@ -79,7 +85,8 @@ declare const ERRORS: {
|
|
|
79
85
|
readonly invalid_request: 400;
|
|
80
86
|
/** §3.3 — a request handled only with an extension the Personal Agent does not list. */
|
|
81
87
|
readonly extension_required: 403;
|
|
82
|
-
|
|
88
|
+
/** Answered as a challenge without an error code (§7): the request needs the account. */
|
|
89
|
+
readonly account_required: 401;
|
|
83
90
|
readonly not_found: 404;
|
|
84
91
|
readonly method_not_allowed: 405;
|
|
85
92
|
readonly request_too_large: 413;
|
|
@@ -88,7 +95,7 @@ declare const ERRORS: {
|
|
|
88
95
|
};
|
|
89
96
|
export type PoppyErrorCode = keyof typeof ERRORS;
|
|
90
97
|
/**
|
|
91
|
-
* A Poppy error, answered as `{ "error": code, … }` like an OAuth error response (§
|
|
98
|
+
* A Poppy error, answered as `{ "error": code, … }` like an OAuth error response (§8.13). `extra`
|
|
92
99
|
* carries what a code adds — `conversation_id` for `direct_conversation_open`, `extension` for
|
|
93
100
|
* `extension_required`. An app hook may throw one to refuse a request.
|
|
94
101
|
*/
|
|
@@ -107,18 +114,18 @@ export declare function derivedPoppyId(prefix: 'msg', seed: string): string;
|
|
|
107
114
|
/** A validated `POST {endpoint}` / `POST {endpoint}/{id}/messages` body. */
|
|
108
115
|
export interface PoppySendBody {
|
|
109
116
|
message: PoppyInboundMessage;
|
|
110
|
-
/** Only on `POST {endpoint}`: start a Direct Conversation under this one (§
|
|
117
|
+
/** Only on `POST {endpoint}`: start a Direct Conversation under this one (§8.10). */
|
|
111
118
|
parentConversationId?: string;
|
|
112
119
|
}
|
|
113
120
|
/**
|
|
114
|
-
* Parse a message request (§
|
|
121
|
+
* Parse a message request (§8.3, §8.4). Unknown fields — on the body, the message or its context —
|
|
115
122
|
* are ignored, never refused (§3.3). Only the fields the protocol defines are kept.
|
|
116
123
|
*/
|
|
117
124
|
export declare function parseSendBody(raw: string, opts: {
|
|
118
125
|
allowParent: boolean;
|
|
119
126
|
}): PoppySendBody;
|
|
120
127
|
/**
|
|
121
|
-
* The fingerprint a retry is compared by (§
|
|
128
|
+
* The fingerprint a retry is compared by (§8.3): the message's content and, for a first message,
|
|
122
129
|
* the conversation it was addressed to. Unknown fields were dropped by the parser, so a retry that
|
|
123
130
|
* adds one is still the same message.
|
|
124
131
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../src/poppy/protocol.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,sDAAsD;AACtD,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAE5C,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAE3C,
|
|
1
|
+
{"version":3,"file":"protocol.d.ts","sourceRoot":"","sources":["../../../src/poppy/protocol.ts"],"names":[],"mappings":"AAEA;;;;;;;;GAQG;AAEH,sDAAsD;AACtD,eAAO,MAAM,sBAAsB,QAAQ,CAAC;AAE5C,mFAAmF;AACnF,eAAO,MAAM,mBAAmB,UAAU,CAAC;AAE3C,MAAM,MAAM,WAAW,GAAG,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;AACnE,MAAM,MAAM,cAAc,GAAG,OAAO,GAAG,OAAO,CAAC;AAC/C,MAAM,MAAM,eAAe,GAAG,OAAO,GAAG,OAAO,CAAC;AAEhD,uFAAuF;AACvF,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,eAAe,CAAC;IACtB,EAAE,CAAC,EAAE,MAAM,CAAC;IACZ,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,8EAA8E;AAC9E,MAAM,WAAW,YAAY;IAC3B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,CAAC,KAAK,EAAE,MAA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AM,EAAE,KAAK,EAAE,IAAI,EAAE,MAAM,GAAG,MAAM,CAElE;AAMD,4EAA4E;AAC5E,MAAM,WAAW,aAAa;IAC5B,OAAO,EAAE,mBAAmB,CAAC;IAC7B,qFAAqF;IACrF,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,MAAM,EAAE,IAAI,EAAE;IAAE,WAAW,EAAE,OAAO,CAAA;CAAE,GAAG,aAAa,CA6DxF;AAeD;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,aAAa,GAAG,MAAM,CAI9E;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,CAOhD"}
|
|
@@ -1,21 +1,18 @@
|
|
|
1
1
|
import { createHash, randomBytes } from 'node:crypto';
|
|
2
2
|
/**
|
|
3
|
-
* The wire format of Personal Agent Protocol ("Poppy", Draft 0.
|
|
4
|
-
* events, statuses and the error codes of §
|
|
3
|
+
* The wire format of Personal Agent Protocol ("Poppy", Draft 0.3, §7) conversations: messages,
|
|
4
|
+
* events, statuses and the error codes of §8.13. Hand-rolled like the A2A surface — the rules are
|
|
5
5
|
* few and exact, and unknown fields are ignored everywhere (§3.1, §3.3).
|
|
6
6
|
*
|
|
7
|
-
* @experimental Tracks Personal Agent Protocol Draft 0.
|
|
7
|
+
* @experimental Tracks Personal Agent Protocol Draft 0.3 (https://personalagentprotocol.org/docs/spec),
|
|
8
8
|
* a spec still in development: this API WILL change as the spec evolves — possibly in breaking
|
|
9
9
|
* ways, outside semver majors while it is a draft.
|
|
10
10
|
*/
|
|
11
11
|
/** The `protocol_version` this surface implements. */
|
|
12
|
-
export const POPPY_PROTOCOL_VERSION = '0.
|
|
13
|
-
/** The `type` of this surface's entry in `poppy.json` `agent.protocols` (§
|
|
12
|
+
export const POPPY_PROTOCOL_VERSION = '0.3';
|
|
13
|
+
/** The `type` of this surface's entry in `poppy.json` `agent.protocols` (§8.1). */
|
|
14
14
|
export const POPPY_PROTOCOL_TYPE = 'poppy';
|
|
15
|
-
/** The
|
|
16
|
-
export const POPPY_READ_SCOPE = 'poppy:read';
|
|
17
|
-
export const POPPY_WRITE_SCOPE = 'poppy:write';
|
|
18
|
-
/** The conversation errors of §7.13, plus the request errors this surface answers. */
|
|
15
|
+
/** The conversation errors of §8.13, plus the request errors this surface answers. */
|
|
19
16
|
const ERRORS = {
|
|
20
17
|
conversation_not_found: 404,
|
|
21
18
|
conversation_closed: 409,
|
|
@@ -26,7 +23,8 @@ const ERRORS = {
|
|
|
26
23
|
invalid_request: 400,
|
|
27
24
|
/** §3.3 — a request handled only with an extension the Personal Agent does not list. */
|
|
28
25
|
extension_required: 403,
|
|
29
|
-
|
|
26
|
+
/** Answered as a challenge without an error code (§7): the request needs the account. */
|
|
27
|
+
account_required: 401,
|
|
30
28
|
not_found: 404,
|
|
31
29
|
method_not_allowed: 405,
|
|
32
30
|
request_too_large: 413,
|
|
@@ -34,7 +32,7 @@ const ERRORS = {
|
|
|
34
32
|
server_error: 500,
|
|
35
33
|
};
|
|
36
34
|
/**
|
|
37
|
-
* A Poppy error, answered as `{ "error": code, … }` like an OAuth error response (§
|
|
35
|
+
* A Poppy error, answered as `{ "error": code, … }` like an OAuth error response (§8.13). `extra`
|
|
38
36
|
* carries what a code adds — `conversation_id` for `direct_conversation_open`, `extension` for
|
|
39
37
|
* `extension_required`. An app hook may throw one to refuse a request.
|
|
40
38
|
*/
|
|
@@ -58,7 +56,7 @@ export class PoppyError extends Error {
|
|
|
58
56
|
};
|
|
59
57
|
}
|
|
60
58
|
}
|
|
61
|
-
/** IDs are 1–256 characters of the URL-safe base64 alphabet (§
|
|
59
|
+
/** IDs are 1–256 characters of the URL-safe base64 alphabet (§8.2). */
|
|
62
60
|
const ID_PATTERN = /^[A-Za-z0-9_-]{1,256}$/;
|
|
63
61
|
export function isPoppyId(value) {
|
|
64
62
|
return typeof value === 'string' && ID_PATTERN.test(value);
|
|
@@ -75,7 +73,7 @@ function isRecord(value) {
|
|
|
75
73
|
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
76
74
|
}
|
|
77
75
|
/**
|
|
78
|
-
* Parse a message request (§
|
|
76
|
+
* Parse a message request (§8.3, §8.4). Unknown fields — on the body, the message or its context —
|
|
79
77
|
* are ignored, never refused (§3.3). Only the fields the protocol defines are kept.
|
|
80
78
|
*/
|
|
81
79
|
export function parseSendBody(raw, opts) {
|
|
@@ -93,8 +91,9 @@ export function parseSendBody(raw, opts) {
|
|
|
93
91
|
if (!isPoppyId(message.id)) {
|
|
94
92
|
throw new PoppyError('invalid_request', 'message.id must be 1-256 URL-safe base64 characters');
|
|
95
93
|
}
|
|
96
|
-
|
|
97
|
-
|
|
94
|
+
const authorType = isRecord(message.author) ? message.author.type : undefined;
|
|
95
|
+
if (authorType !== 'agent' && authorType !== 'human') {
|
|
96
|
+
throw new PoppyError('invalid_request', 'message.author.type must be "agent" or "human"');
|
|
98
97
|
}
|
|
99
98
|
if (message.text !== undefined && typeof message.text !== 'string') {
|
|
100
99
|
throw new PoppyError('invalid_request', 'message.text must be a string');
|
|
@@ -130,7 +129,7 @@ export function parseSendBody(raw, opts) {
|
|
|
130
129
|
return {
|
|
131
130
|
message: {
|
|
132
131
|
id: message.id,
|
|
133
|
-
|
|
132
|
+
author: { type: authorType },
|
|
134
133
|
...(message.text !== undefined ? { text: message.text } : {}),
|
|
135
134
|
...(message.data !== undefined ? { data: message.data } : {}),
|
|
136
135
|
...(context !== undefined ? { context: { ...context } } : {}),
|
|
@@ -152,7 +151,7 @@ function canonical(value) {
|
|
|
152
151
|
return JSON.stringify(value) ?? 'null';
|
|
153
152
|
}
|
|
154
153
|
/**
|
|
155
|
-
* The fingerprint a retry is compared by (§
|
|
154
|
+
* The fingerprint a retry is compared by (§8.3): the message's content and, for a first message,
|
|
156
155
|
* the conversation it was addressed to. Unknown fields were dropped by the parser, so a retry that
|
|
157
156
|
* adds one is still the same message.
|
|
158
157
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/poppy/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtD;;;;;;;;GAQG;AAEH,sDAAsD;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAE5C,mFAAmF;AACnF,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/poppy/protocol.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAEtD;;;;;;;;GAQG;AAEH,sDAAsD;AACtD,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,CAAC;AAE5C,mFAAmF;AACnF,MAAM,CAAC,MAAM,mBAAmB,GAAG,OAAO,CAAC;AAiE3C,sFAAsF;AACtF,MAAM,MAAM,GAAG;IACb,sBAAsB,EAAE,GAAG;IAC3B,mBAAmB,EAAE,GAAG;IACxB,wBAAwB,EAAE,GAAG;IAC7B,mBAAmB,EAAE,GAAG;IACxB,cAAc,EAAE,GAAG;IACnB,cAAc,EAAE,GAAG;IACnB,eAAe,EAAE,GAAG;IACpB,wFAAwF;IACxF,kBAAkB,EAAE,GAAG;IACvB,yFAAyF;IACzF,gBAAgB,EAAE,GAAG;IACrB,SAAS,EAAE,GAAG;IACd,kBAAkB,EAAE,GAAG;IACvB,iBAAiB,EAAE,GAAG;IACtB,eAAe,EAAE,GAAG;IACpB,YAAY,EAAE,GAAG;CACT,CAAC;AAIX;;;;GAIG;AACH,MAAM,OAAO,UAAW,SAAQ,KAAK;IAExB,IAAI;IAEJ,KAAK;IAHhB,YACW,IAAoB,EAC7B,WAAoB,EACX,KAAK,GAA4B,EAAE;QA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,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;aACzC,GAAG,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,IAAI,SAAS,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC;aAC/D,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC;IAClB,CAAC;IACD,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,MAAM,CAAC;AACzC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,kBAAkB,CAAC,MAAc,EAAE,IAAmB;IACpE,OAAO,UAAU,CAAC,QAAQ,CAAC;SACxB,MAAM,CAAC,SAAS,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,oBAAoB,IAAI,IAAI,EAAE,GAAG,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC;SACzF,MAAM,CAAC,WAAW,CAAC,CAAC;AACzB,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,GAAW;IACxC,IAAI,GAAG,CAAC,IAAI,EAAE,KAAK,EAAE;QAAE,OAAO;IAC9B,IAAI,CAAC;QACH,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC;IAClB,CAAC;IAAC,MAAM,CAAC;QACP,MAAM,IAAI,UAAU,CAAC,iBAAiB,EAAE,oCAAoC,CAAC,CAAC;IAChF,CAAC;AACH,CAAC"}
|
|
@@ -19,7 +19,7 @@ export interface RedisPoppyStoreOptions {
|
|
|
19
19
|
* appends never share one; a message claim, an event key and the reader lease are `SET … NX`.
|
|
20
20
|
* Conversations are JSON values; events one key each (`…:evt:<conversation>:<seq>`).
|
|
21
21
|
*
|
|
22
|
-
* @experimental Tracks Personal Agent Protocol Draft 0.
|
|
22
|
+
* @experimental Tracks Personal Agent Protocol Draft 0.3 (https://personalagentprotocol.org/docs/spec),
|
|
23
23
|
* a spec still in development: this API WILL change as the spec evolves — possibly in breaking
|
|
24
24
|
* ways, outside semver majors while it is a draft.
|
|
25
25
|
*/
|
|
@@ -5,7 +5,7 @@ const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
|
5
5
|
* appends never share one; a message claim, an event key and the reader lease are `SET … NX`.
|
|
6
6
|
* Conversations are JSON values; events one key each (`…:evt:<conversation>:<seq>`).
|
|
7
7
|
*
|
|
8
|
-
* @experimental Tracks Personal Agent Protocol Draft 0.
|
|
8
|
+
* @experimental Tracks Personal Agent Protocol Draft 0.3 (https://personalagentprotocol.org/docs/spec),
|
|
9
9
|
* a spec still in development: this API WILL change as the spec evolves — possibly in breaking
|
|
10
10
|
* ways, outside semver majors while it is a draft.
|
|
11
11
|
*/
|
|
@@ -4,8 +4,8 @@ import type { PoppyContext, PoppyEvent, PoppyEventBody, PoppyResponder, PoppySta
|
|
|
4
4
|
/**
|
|
5
5
|
* A Poppy conversation as this surface keeps it. It belongs to a Personal Agent (`clientId`) and
|
|
6
6
|
* one of its Users (`userId`); once it used an account here, to that account too (`accountRef`,
|
|
7
|
-
* §
|
|
8
|
-
* parent's thread, which is how the Company Agent knows what was said in either (§
|
|
7
|
+
* §8.2). The agent side of it is an agent thread (`threadId`) — a Direct Conversation shares its
|
|
8
|
+
* parent's thread, which is how the Company Agent knows what was said in either (§8.10).
|
|
9
9
|
*/
|
|
10
10
|
export interface PoppyConversationRecord {
|
|
11
11
|
id: string;
|
|
@@ -20,7 +20,7 @@ export interface PoppyConversationRecord {
|
|
|
20
20
|
openDirectId: string | null;
|
|
21
21
|
status: PoppyStatus;
|
|
22
22
|
responder: PoppyResponder;
|
|
23
|
-
/** The User's context as last shared — fields a message leaves out keep their value (§
|
|
23
|
+
/** The User's context as last shared — fields a message leaves out keep their value (§8.4). */
|
|
24
24
|
context: PoppyContext;
|
|
25
25
|
/** The run whose reply is being written, while there is one. */
|
|
26
26
|
activeRunId: string | null;
|
|
@@ -36,7 +36,7 @@ export interface PoppyConversationRecord {
|
|
|
36
36
|
createdAt: number;
|
|
37
37
|
updatedAt: number;
|
|
38
38
|
}
|
|
39
|
-
/** The identity a conversation's turns run as: that of its latest request (§
|
|
39
|
+
/** The identity a conversation's turns run as: that of its latest request (§8.11). */
|
|
40
40
|
export interface PoppyGrant {
|
|
41
41
|
actor: Actor;
|
|
42
42
|
/** The token's account scopes; empty when signed out. */
|
|
@@ -49,7 +49,7 @@ export interface StoredPoppyEvent {
|
|
|
49
49
|
seq: number;
|
|
50
50
|
event: PoppyEvent;
|
|
51
51
|
}
|
|
52
|
-
/** What an accepted message keeps for its retries (§
|
|
52
|
+
/** What an accepted message keeps for its retries (§8.3). */
|
|
53
53
|
export interface PoppyMessageReceipt {
|
|
54
54
|
fingerprint: string;
|
|
55
55
|
conversationId: string;
|
|
@@ -68,7 +68,7 @@ export type PoppyMessageClaim = {
|
|
|
68
68
|
* Where conversations, their events and message receipts live. Events are append-only and read by
|
|
69
69
|
* position, so a cursor replays exactly what came after it, on any replica.
|
|
70
70
|
*
|
|
71
|
-
* @experimental Tracks Personal Agent Protocol Draft 0.
|
|
71
|
+
* @experimental Tracks Personal Agent Protocol Draft 0.3 (https://personalagentprotocol.org/docs/spec),
|
|
72
72
|
* a spec still in development: this API WILL change as the spec evolves — possibly in breaking
|
|
73
73
|
* ways, outside semver majors while it is a draft.
|
|
74
74
|
*/
|
|
@@ -155,7 +155,7 @@ export declare const POPPY_TABLES: {
|
|
|
155
155
|
* `CREATE TABLE IF NOT EXISTS` DDL for the Poppy tables — the agent tables' portable dialect
|
|
156
156
|
* (quoted identifiers, epoch-ms `BIGINT`, `TEXT` JSON; `forDialect` adapts it to MySQL). An event's
|
|
157
157
|
* primary key is its position, so two appends racing for one position cannot both win; a message's
|
|
158
|
-
* is its (owner, id), the idempotency lock of §
|
|
158
|
+
* is its (owner, id), the idempotency lock of §8.3.
|
|
159
159
|
*/
|
|
160
160
|
export declare function poppyTableStatements(): string[];
|
|
161
161
|
/** Create the Poppy tables if missing. Idempotent. */
|
package/dist/src/poppy/store.js
CHANGED
|
@@ -112,7 +112,7 @@ export const POPPY_TABLES = {
|
|
|
112
112
|
* `CREATE TABLE IF NOT EXISTS` DDL for the Poppy tables — the agent tables' portable dialect
|
|
113
113
|
* (quoted identifiers, epoch-ms `BIGINT`, `TEXT` JSON; `forDialect` adapts it to MySQL). An event's
|
|
114
114
|
* primary key is its position, so two appends racing for one position cannot both win; a message's
|
|
115
|
-
* is its (owner, id), the idempotency lock of §
|
|
115
|
+
* is its (owner, id), the idempotency lock of §8.3.
|
|
116
116
|
*/
|
|
117
117
|
export function poppyTableStatements() {
|
|
118
118
|
const t = POPPY_TABLES;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { CompanyClient } from './company.js';
|
|
2
2
|
import type { PoppyApiEntry } from './types.js';
|
|
3
|
-
/** API types this client understands (section
|
|
3
|
+
/** API types this client understands (section 7). Others are skipped. */
|
|
4
4
|
export declare const KNOWN_API_TYPES: string[];
|
|
5
5
|
export declare function listApis(company: CompanyClient): PoppyApiEntry[];
|
|
6
6
|
export declare function pickApi(company: CompanyClient, type: 'openapi' | 'mcp', index?: number | undefined): PoppyApiEntry;
|
|
@@ -14,13 +14,14 @@ export interface OpenApiDoc {
|
|
|
14
14
|
}>>;
|
|
15
15
|
[k: string]: unknown;
|
|
16
16
|
}
|
|
17
|
-
/** Loads an OpenAPI description. Tried
|
|
17
|
+
/** Loads an OpenAPI description. Tried as a public document first; through the Session if that's refused. */
|
|
18
18
|
export declare function loadOpenApi(company: CompanyClient, api: PoppyApiEntry): Promise<OpenApiDoc>;
|
|
19
19
|
/** The API's base URL: `servers[0].url` resolved against the description's URL. */
|
|
20
20
|
export declare function apiBaseUrl(doc: OpenApiDoc, api: PoppyApiEntry): string;
|
|
21
21
|
/**
|
|
22
|
-
* Calls an endpoint of a listed OpenAPI API
|
|
23
|
-
* absolute URLs outside the API's own origin, so
|
|
22
|
+
* Calls an endpoint of a listed OpenAPI API (section 7), through the Session and, when signed in,
|
|
23
|
+
* with an access token. Refuses absolute URLs outside the API's own origin, so nothing goes to a
|
|
24
|
+
* third party.
|
|
24
25
|
*/
|
|
25
26
|
export declare function callOpenApi(company: CompanyClient, input: {
|
|
26
27
|
method: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/poppy-client/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAIlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,yEAAyE;AACzE,eAAO,MAAM,eAAe,UAAqB,CAAC;AAElD,wBAAgB,QAAQ,CAAC,OAAO,EAAE,aAAa,GAAG,aAAa,EAAE,CAIhE;AAED,wBAAgB,OAAO,CACrB,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,SAAS,GAAG,KAAK,EACvB,KAAK,CAAC,EAAE,MAAM,GAAG,SAAS,GACzB,aAAa,CAOf;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,CAAC,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,EAAE,GAAG,SAAS,CAAC;IACxC,KAAK,CAAC,EAAE,MAAM,CACZ,MAAM,EACN,MAAM,CAAC,MAAM,EAAE;QAAE,OAAO,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;QAAC,WAAW,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE,CAAC,CACnF,CAAC;IACF,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CACtB;AAED,
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../../src/poppy-client/api.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAIlD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AAGhD,yEAAyE;AACzE,eAAO,MAAM,eAAe,UAAqB,CAAC;AAElD,wBAAg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
|
|
|
2
2
|
import { PoppyError } from './errors.js';
|
|
3
3
|
import { readJson } from './http.js';
|
|
4
4
|
import { requireSecureUrl } from './util.js';
|
|
5
|
-
/** API types this client understands (section
|
|
5
|
+
/** API types this client understands (section 7). Others are skipped. */
|
|
6
6
|
export const KNOWN_API_TYPES = ['openapi', 'mcp'];
|
|
7
7
|
export function listApis(company) {
|
|
8
8
|
return (company.document.apis ?? []).filter((a) => a && KNOWN_API_TYPES.includes(a.type) && typeof a.url === 'string');
|
|
@@ -17,7 +17,7 @@ export function pickApi(company, type, index) {
|
|
|
17
17
|
requireSecureUrl(api.url, `${type} url`, company.security);
|
|
18
18
|
return api;
|
|
19
19
|
}
|
|
20
|
-
/** Loads an OpenAPI description. Tried
|
|
20
|
+
/** Loads an OpenAPI description. Tried as a public document first; through the Session if that's refused. */
|
|
21
21
|
export async function loadOpenApi(company, api) {
|
|
22
22
|
const res = await company.http.request(api.url, { headers: { accept: 'application/json' } });
|
|
23
23
|
if (res.ok)
|
|
@@ -25,7 +25,7 @@ export async function loadOpenApi(company, api) {
|
|
|
25
25
|
if (res.status === 401 || res.status === 403) {
|
|
26
26
|
const { body } = await company.json(api.url, {
|
|
27
27
|
headers: { accept: 'application/json' },
|
|
28
|
-
|
|
28
|
+
service: api.url,
|
|
29
29
|
});
|
|
30
30
|
return body ?? {};
|
|
31
31
|
}
|
|
@@ -37,8 +37,9 @@ export function apiBaseUrl(doc, api) {
|
|
|
37
37
|
return new URL(server ?? '/', api.url).toString().replace(/\/+$/, '');
|
|
38
38
|
}
|
|
39
39
|
/**
|
|
40
|
-
* Calls an endpoint of a listed OpenAPI API
|
|
41
|
-
* absolute URLs outside the API's own origin, so
|
|
40
|
+
* Calls an endpoint of a listed OpenAPI API (section 7), through the Session and, when signed in,
|
|
41
|
+
* with an access token. Refuses absolute URLs outside the API's own origin, so nothing goes to a
|
|
42
|
+
* third party.
|
|
42
43
|
*/
|
|
43
44
|
export async function callOpenApi(company, input) {
|
|
44
45
|
const api = pickApi(company, 'openapi', input.apiIndex);
|
|
@@ -49,7 +50,7 @@ export async function callOpenApi(company, input) {
|
|
|
49
50
|
: new URL(base + (input.path.startsWith('/') ? input.path : `/${input.path}`));
|
|
50
51
|
const allowed = new Set([new URL(base).origin, new URL(api.url).origin]);
|
|
51
52
|
if (!allowed.has(url.origin)) {
|
|
52
|
-
throw new PoppyError('foreign_origin', `${url.origin} is not this API's origin; refusing to send
|
|
53
|
+
throw new PoppyError('foreign_origin', `${url.origin} is not this API's origin; refusing to send credentials`);
|
|
53
54
|
}
|
|
54
55
|
requireSecureUrl(url.toString(), 'API URL', company.security);
|
|
55
56
|
const headers = { accept: 'application/json' };
|
|
@@ -59,11 +60,15 @@ export async function callOpenApi(company, input) {
|
|
|
59
60
|
method: input.method.toUpperCase(),
|
|
60
61
|
headers,
|
|
61
62
|
body: input.body === undefined ? undefined : JSON.stringify(input.body),
|
|
62
|
-
|
|
63
|
+
service: base,
|
|
63
64
|
scope: input.scope,
|
|
64
65
|
});
|
|
65
|
-
if (res.status === 401 || res.status === 403) {
|
|
66
|
-
|
|
66
|
+
if ((res.status === 401 || res.status === 403) && res.headers.get('www-authenticate')) {
|
|
67
|
+
await throwForResponse(res);
|
|
68
|
+
}
|
|
69
|
+
if (res.status === 400) {
|
|
70
|
+
const refused = await readJson(res.clone());
|
|
71
|
+
if (refused?.error === 'invalid_session')
|
|
67
72
|
await throwForResponse(res);
|
|
68
73
|
}
|
|
69
74
|
const text = await res.text();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../../src/poppy-client/api.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAErC,OAAO,EAAE,gBAAgB,EAAE,MAAM,WAAW,CAAC;AAE7C,yEAAyE;AACz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;QACvE,OAAO,EAAE,IAAI;QACb,KAAK,EAAE,KAAK,CAAC,KAAK;KACnB,CAAC,CAAC;IACH,IAAI,CAAC,GAAG,CAAC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,IAAI,GAAG,CAAC,OAAO,CAAC,GAAG,CAAC,kBAAkB,CAAC,EAAE,CAAC;QACtF,MAAM,gBAAgB,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IACD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;QACvB,MAAM,OAAO,GAAG,MAAM,QAAQ,CAAqB,GAAG,CAAC,KAAK,EAAE,CAAC,CAAC;QAChE,IAAI,OAAO,EAAE,KAAK,KAAK,iBAAiB;YAAE,MAAM,gBAAgB,CAAC,GAAG,CAAC,CAAC;IACxE,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;IAC9B,IAAI,IAAI,GAAY,IAAI,CAAC;IACzB,IAAI,CAAC;QACH,IAAI,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IAC7C,CAAC;IAAC,MAAM,CAAC,CAAA,CAAC;IACV,OAAO,EAAE,MAAM,EAAE,GAAG,CAAC,MAAM,EAAE,OAAO,EAAE,GAAG,CAAC,OAAO,EAAE,IAAI,EAAE,CAAC;AAC5D,CAAC"}
|
|
@@ -1,24 +1,18 @@
|
|
|
1
1
|
import type { CompanyClient } from './company.js';
|
|
2
|
+
/** Where the Personal Agent's browser joins a Session (section 6), or an error without one. */
|
|
3
|
+
export declare function browserSessionEndpoint(company: CompanyClient): string;
|
|
2
4
|
/**
|
|
3
|
-
*
|
|
4
|
-
*
|
|
5
|
+
* Step 2: reads the one-time code from the HTML of the page the agent's OWN browser loaded in step
|
|
6
|
+
* 1 (section 6). Pass it nothing else: a code from anywhere else may come from someone else's
|
|
7
|
+
* browser, which would then join the User's Session (10.6). Keep the code out of model context.
|
|
5
8
|
*/
|
|
6
|
-
export declare function
|
|
7
|
-
endpoint: string;
|
|
8
|
-
assertion: string;
|
|
9
|
-
sessionId: string;
|
|
10
|
-
}>;
|
|
11
|
-
/** A page whose form POSTs the assertion as a top-level navigation. Never in the URL (5). */
|
|
12
|
-
export declare function autoSubmitFormHtml(endpoint: string, assertion: string): string;
|
|
9
|
+
export declare function browserJoinCode(html: string): string;
|
|
13
10
|
/**
|
|
14
|
-
*
|
|
15
|
-
*
|
|
11
|
+
* Step 2: authorizes the code with the Session header and, if signed in, the access token, which
|
|
12
|
+
* never reaches the browser. The agent's browser then submits the form (step 3); after a failure,
|
|
13
|
+
* start again at step 1.
|
|
16
14
|
*/
|
|
17
|
-
export declare function
|
|
18
|
-
|
|
19
|
-
}): Promise<
|
|
20
|
-
url: string;
|
|
21
|
-
served: Promise<void>;
|
|
22
|
-
close: () => void;
|
|
23
|
-
}>;
|
|
15
|
+
export declare function authorizeBrowserJoin(company: CompanyClient, code: string, opts?: {
|
|
16
|
+
signedOut?: boolean | undefined;
|
|
17
|
+
}): Promise<void>;
|
|
24
18
|
//# sourceMappingURL=browser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/poppy-client/browser.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"browser.d.ts","sourceRoot":"","sources":["../../../src/poppy-client/browser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAKlD,+FAA+F;AAC/F,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,aAAa,GAAG,MAAM,CASrE;AAED;;;;GAIG;AACH,wBAAgB,eAAe,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQpD;AAED;;;;GAIG;AACH,wBAAsB,oBAAoB,CACxC,OAAO,EAAE,aAAa,EACtB,IAAI,EAAE,MAAM,EACZ,IAAI,GAAE;IAAE,SAAS,CAAC,EAAE,OAAO,GAAG,SAAS,CAAA;CAAO,GAC7C,OAAO,CAAC,IAAI,CAAC,CAWf"}
|