@agimon-ai/po-core 0.0.0-alpha.151 → 0.0.0-alpha.152

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.
@@ -130,6 +130,11 @@ const GATED_ROUTES = [
130
130
  pattern: /^\/api\/workspaces\/[^/]+\/plugins\/mcp\/repository\/authorize\/[^/]+$/u,
131
131
  action: "mcp.authorize"
132
132
  },
133
+ {
134
+ method: "POST",
135
+ pattern: /^\/api\/workspaces\/[^/]+\/plugins\/mcp\/repository\/secrets$/u,
136
+ action: "mcp.authorize"
137
+ },
133
138
  {
134
139
  method: "POST",
135
140
  pattern: /^\/api\/workspaces\/[^/]+\/sessions\/[^/]+\/mcp\/clients$/u,
@@ -1 +1 @@
1
- {"version":3,"file":"index.cjs","names":[],"sources":["../../../../src/services/webauthnPolicy/index.ts"],"sourcesContent":["/**\n * What a passkey is allowed to prove, and for how long.\n *\n * A session cookie is a bearer token: whoever holds the bytes is you. A passkey\n * is a private key in the device's secure enclave that never leaves it, so the\n * cookie stops being the only thing between a stolen phone and this machine.\n * The cookie does not go away, because a WebSocket cannot run a ceremony per\n * frame; what changes is that the cookie is short-lived, re-mintable with a\n * gesture rather than a QR, and insufficient on its own for the actions below.\n *\n * The crypto lives in the adapter. This file is the policy: which actions need\n * a fresh signature, how long a challenge is good for, and when a counter says\n * the credential has been cloned.\n */\n\n/**\n * Actions that need a fresh gesture even from a live session.\n *\n * These are escalation paths rather than ordinary prompting or tool approval:\n * credentials redirect machine traffic, sessions run code in a selected directory,\n * repository writes change future sessions, and live MCP operations may start local\n * processes or contact remote servers.\n */\nexport const STEP_UP_ACTIONS = [\n 'provider.login',\n 'provider.logout',\n 'session.create',\n 'settings.write',\n 'mcp.discover',\n 'mcp.authorize',\n 'computer-use.activate',\n // Revoking a trusted native device ends every session it holds; from a remote caller it needs a\n // fresh gesture so a stolen cookie cannot lock the owner's phone out.\n 'device.revoke',\n 'peer.link',\n] as const;\n\nexport type StepUpAction = (typeof STEP_UP_ACTIONS)[number];\n\n/** Short enough that a captured challenge is useless, long enough for a slow Face ID. */\nexport const STEP_UP_CHALLENGE_TTL_MS = 60_000;\n/** A registration or sign-in ceremony the user has to complete. */\nexport const CEREMONY_TTL_MS = 120_000;\n\n/**\n * Which action, if any, a request is attempting.\n *\n * Matched here rather than at each route so the list of gated operations is one\n * readable table instead of three call sites that can drift apart. Anything not\n * named is not gated, which is the safe default only because the gate is an\n * addition to the session check rather than a replacement for it.\n */\nconst GATED_ROUTES: readonly { method: string; pattern: RegExp; action: StepUpAction }[] = [\n { method: 'POST', pattern: /^\\/api\\/plugins\\/session-peer\\/link\\/(?:prepare|accept|unlink)$/u, action: 'peer.link' },\n { method: 'POST', pattern: /^\\/api\\/plugins\\/marketplace\\/installs$/u, action: 'settings.write' },\n { method: 'DELETE', pattern: /^\\/api\\/plugins\\/marketplace\\/installs\\/[^/]+$/u, action: 'settings.write' },\n { method: 'POST', pattern: /^\\/api\\/workspaces$/u, action: 'session.create' },\n {\n method: 'POST',\n // Reviving a recorded session starts an agent in a directory, so it is gated\n // exactly as creating one is.\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/(?:resume|sessions(?:\\/[^/]+\\/(?:resume|revive))?)$/u,\n action: 'session.create',\n },\n // The git new-session dialog starts a worktree session, which runs code in a directory.\n { method: 'POST', pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/git\\/sessions$/u, action: 'session.create' },\n // Choosing a workspace's sandbox changes where its sessions run code.\n { method: 'PATCH', pattern: /^\\/api\\/workspaces\\/[^/]+$/u, action: 'settings.write' },\n // A workspace's git remote credentials redirect what the cockpit pushes and where its token goes.\n { method: 'PUT', pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/git\\/auth$/u, action: 'settings.write' },\n { method: 'POST', pattern: /^\\/api\\/plugins\\/po\\/logins(?:\\/[^/]+\\/answer)?$/u, action: 'provider.login' },\n { method: 'DELETE', pattern: /^\\/api\\/plugins\\/po\\/providers\\/[^/]+$/u, action: 'provider.logout' },\n // The default preset decides which Po plugins every new session loads.\n {\n method: 'PUT',\n pattern:\n /^\\/api(?:\\/workspaces\\/[^/]+)?\\/settings\\/(?:value|repository\\/selection|images|presets(?:\\/(?:create|rename|delete|add-layer|remove-layer))?)$/u,\n action: 'settings.write',\n },\n // Saved MCP configuration changes affect future sessions, like other settings writes.\n { method: 'POST', pattern: /^\\/api(?:\\/workspaces\\/[^/]+)?\\/plugins\\/mcp\\/servers$/u, action: 'settings.write' },\n { method: 'PATCH', pattern: /^\\/api(?:\\/workspaces\\/[^/]+)?\\/plugins\\/mcp\\/servers$/u, action: 'settings.write' },\n { method: 'DELETE', pattern: /^\\/api(?:\\/workspaces\\/[^/]+)?\\/plugins\\/mcp\\/servers$/u, action: 'settings.write' },\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/mcp\\/repository\\/discover$/u,\n action: 'mcp.discover',\n },\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/mcp\\/repository\\/authorize$/u,\n action: 'mcp.authorize',\n },\n {\n method: 'DELETE',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/mcp\\/repository\\/authorize\\/[^/]+$/u,\n action: 'mcp.authorize',\n },\n // Creating a session MCP client hands an outside app a credential into a live session, and\n // revoking one cuts an agent off mid-conversation. Both are gated like the repository revoke.\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/sessions\\/[^/]+\\/mcp\\/clients$/u,\n action: 'mcp.authorize',\n },\n {\n method: 'DELETE',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/sessions\\/[^/]+\\/mcp\\/clients\\/[^/]+$/u,\n action: 'mcp.authorize',\n },\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/sessions\\/[^/]+\\/plugins\\/computer-use\\/activate$/u,\n action: 'computer-use.activate',\n },\n { method: 'DELETE', pattern: /^\\/api\\/remote\\/trusted-devices\\/[^/]+$/u, action: 'device.revoke' },\n];\nexport function stepUpActionFor(method: string, path: string): StepUpAction | undefined {\n const wanted = method.toUpperCase();\n return GATED_ROUTES.find((route) => route.method === wanted && route.pattern.test(path))?.action;\n}\n\nexport function isStepUpAction(value: unknown): value is StepUpAction {\n return typeof value === 'string' && (STEP_UP_ACTIONS as readonly string[]).includes(value);\n}\n\nexport interface StoredCredential {\n /** Opaque handle for display and revocation. */\n id: string;\n /** The authenticator's credential id, base64url, as WebAuthn reports it. */\n credentialId: string;\n /** Base64url public key; the private half never leaves the device. */\n publicKey: string;\n /** Signature counter, for clone detection. */\n counter: number;\n transports: string[];\n label: string;\n createdAt: number;\n lastUsedAt: number;\n}\n\nexport type CounterVerdict = 'ok' | 'clone-suspected';\n\n/**\n * Whether a signature counter moved the way a real authenticator moves it.\n *\n * A counter that stays at zero means the authenticator does not implement one,\n * which is common and not a signal. A counter that goes backwards or repeats\n * while claiming to count means two things are signing with the same key, which\n * is the definition of a cloned credential.\n */\nexport function counterVerdict(stored: number, presented: number): CounterVerdict {\n if (stored === 0 && presented === 0) return 'ok';\n return presented > stored ? 'ok' : 'clone-suspected';\n}\n\n/** Whether a ceremony or step-up challenge is still live. */\nexport function challengeIsFresh(issuedAt: number, now: number, ttlMs: number): boolean {\n return now - issuedAt < ttlMs;\n}\n\n/** A quick tunnel's domain; its hostname rotates on every start. */\nconst ROTATING_SUFFIX = '.trycloudflare.com';\nexport function isQuickTunnelHost(origin: string | undefined): boolean {\n if (origin === undefined) return false;\n try {\n return new URL(origin).hostname.toLowerCase().endsWith(ROTATING_SUFFIX);\n } catch {\n return false;\n }\n}\n/** Dotted-quad, and the bracketed form a URL uses for v6. */\nconst IPV4 = /^\\d{1,3}(?:\\.\\d{1,3}){3}$/u;\n\n/**\n * The relying party id a passkey is bound to.\n *\n * Derived from the configured tunnel hostname and nothing else, never from a\n * request header: `rpID` is the entire scope of a credential, so a caller who\n * could influence it could mint credentials against somebody else's origin.\n *\n * Three things are refused rather than accepted and regretted later:\n *\n * - A quick tunnel, whose hostname rotates on every start, so a passkey\n * registered now would silently stop working on the next one.\n * - An IP address, which WebAuthn does not accept as a relying party id at all;\n * registering against one fails in the browser rather than here, which is a\n * much worse place to find out.\n * - Anything without a dot, which cannot be a public tunnel hostname.\n */\nexport function relyingPartyId(publicOrigin: string | undefined): string | undefined {\n if (publicOrigin === undefined) return undefined;\n let host: string;\n try {\n host = new URL(publicOrigin).hostname.toLowerCase();\n } catch {\n return undefined;\n }\n if (isQuickTunnelHost(publicOrigin)) return undefined;\n if (IPV4.test(host) || host.startsWith('[')) return undefined;\n if (!host.includes('.')) return undefined;\n return host;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CACA;AACF;;AAKA,MAAa,2BAA2B;;AAExC,MAAa,kBAAkB;;;;;;;;;AAU/B,MAAM,eAAqF;CACzF;EAAE,QAAQ;EAAQ,SAAS;EAAoE,QAAQ;CAAY;CACnH;EAAE,QAAQ;EAAQ,SAAS;EAA4C,QAAQ;CAAiB;CAChG;EAAE,QAAQ;EAAU,SAAS;EAAmD,QAAQ;CAAiB;CACzG;EAAE,QAAQ;EAAQ,SAAS;EAAwB,QAAQ;CAAiB;CAC5E;EACE,QAAQ;EAGR,SAAS;EACT,QAAQ;CACV;CAEA;EAAE,QAAQ;EAAQ,SAAS;EAAuD,QAAQ;CAAiB;CAE3G;EAAE,QAAQ;EAAS,SAAS;EAA+B,QAAQ;CAAiB;CAEpF;EAAE,QAAQ;EAAO,SAAS;EAAmD,QAAQ;CAAiB;CACtG;EAAE,QAAQ;EAAQ,SAAS;EAAqD,QAAQ;CAAiB;CACzG;EAAE,QAAQ;EAAU,SAAS;EAA2C,QAAQ;CAAkB;CAElG;EACE,QAAQ;EACR,SACE;EACF,QAAQ;CACV;CAEA;EAAE,QAAQ;EAAQ,SAAS;EAA2D,QAAQ;CAAiB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AAO,IAAI,IAAI,YAAY,CAAC,CAAC,SAAS,YAAY;CACpD,QAAQ;EACN;CACF;CACA,IAAI,kBAAkB,YAAY,GAAG,OAAO,KAAA;CAC5C,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,WAAW,GAAG,GAAG,OAAO,KAAA;CACpD,IAAI,CAAC,KAAK,SAAS,GAAG,GAAG,OAAO,KAAA;CAChC,OAAO;AACT"}
1
+ {"version":3,"file":"index.cjs","names":[],"sources":["../../../../src/services/webauthnPolicy/index.ts"],"sourcesContent":["/**\n * What a passkey is allowed to prove, and for how long.\n *\n * A session cookie is a bearer token: whoever holds the bytes is you. A passkey\n * is a private key in the device's secure enclave that never leaves it, so the\n * cookie stops being the only thing between a stolen phone and this machine.\n * The cookie does not go away, because a WebSocket cannot run a ceremony per\n * frame; what changes is that the cookie is short-lived, re-mintable with a\n * gesture rather than a QR, and insufficient on its own for the actions below.\n *\n * The crypto lives in the adapter. This file is the policy: which actions need\n * a fresh signature, how long a challenge is good for, and when a counter says\n * the credential has been cloned.\n */\n\n/**\n * Actions that need a fresh gesture even from a live session.\n *\n * These are escalation paths rather than ordinary prompting or tool approval:\n * credentials redirect machine traffic, sessions run code in a selected directory,\n * repository writes change future sessions, and live MCP operations may start local\n * processes or contact remote servers.\n */\nexport const STEP_UP_ACTIONS = [\n 'provider.login',\n 'provider.logout',\n 'session.create',\n 'settings.write',\n 'mcp.discover',\n 'mcp.authorize',\n 'computer-use.activate',\n // Revoking a trusted native device ends every session it holds; from a remote caller it needs a\n // fresh gesture so a stolen cookie cannot lock the owner's phone out.\n 'device.revoke',\n 'peer.link',\n] as const;\n\nexport type StepUpAction = (typeof STEP_UP_ACTIONS)[number];\n\n/** Short enough that a captured challenge is useless, long enough for a slow Face ID. */\nexport const STEP_UP_CHALLENGE_TTL_MS = 60_000;\n/** A registration or sign-in ceremony the user has to complete. */\nexport const CEREMONY_TTL_MS = 120_000;\n\n/**\n * Which action, if any, a request is attempting.\n *\n * Matched here rather than at each route so the list of gated operations is one\n * readable table instead of three call sites that can drift apart. Anything not\n * named is not gated, which is the safe default only because the gate is an\n * addition to the session check rather than a replacement for it.\n */\nconst GATED_ROUTES: readonly { method: string; pattern: RegExp; action: StepUpAction }[] = [\n { method: 'POST', pattern: /^\\/api\\/plugins\\/session-peer\\/link\\/(?:prepare|accept|unlink)$/u, action: 'peer.link' },\n { method: 'POST', pattern: /^\\/api\\/plugins\\/marketplace\\/installs$/u, action: 'settings.write' },\n { method: 'DELETE', pattern: /^\\/api\\/plugins\\/marketplace\\/installs\\/[^/]+$/u, action: 'settings.write' },\n { method: 'POST', pattern: /^\\/api\\/workspaces$/u, action: 'session.create' },\n {\n method: 'POST',\n // Reviving a recorded session starts an agent in a directory, so it is gated\n // exactly as creating one is.\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/(?:resume|sessions(?:\\/[^/]+\\/(?:resume|revive))?)$/u,\n action: 'session.create',\n },\n // The git new-session dialog starts a worktree session, which runs code in a directory.\n { method: 'POST', pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/git\\/sessions$/u, action: 'session.create' },\n // Choosing a workspace's sandbox changes where its sessions run code.\n { method: 'PATCH', pattern: /^\\/api\\/workspaces\\/[^/]+$/u, action: 'settings.write' },\n // A workspace's git remote credentials redirect what the cockpit pushes and where its token goes.\n { method: 'PUT', pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/git\\/auth$/u, action: 'settings.write' },\n { method: 'POST', pattern: /^\\/api\\/plugins\\/po\\/logins(?:\\/[^/]+\\/answer)?$/u, action: 'provider.login' },\n { method: 'DELETE', pattern: /^\\/api\\/plugins\\/po\\/providers\\/[^/]+$/u, action: 'provider.logout' },\n // The default preset decides which Po plugins every new session loads.\n {\n method: 'PUT',\n pattern:\n /^\\/api(?:\\/workspaces\\/[^/]+)?\\/settings\\/(?:value|repository\\/selection|images|presets(?:\\/(?:create|rename|delete|add-layer|remove-layer))?)$/u,\n action: 'settings.write',\n },\n // Saved MCP configuration changes affect future sessions, like other settings writes.\n { method: 'POST', pattern: /^\\/api(?:\\/workspaces\\/[^/]+)?\\/plugins\\/mcp\\/servers$/u, action: 'settings.write' },\n { method: 'PATCH', pattern: /^\\/api(?:\\/workspaces\\/[^/]+)?\\/plugins\\/mcp\\/servers$/u, action: 'settings.write' },\n { method: 'DELETE', pattern: /^\\/api(?:\\/workspaces\\/[^/]+)?\\/plugins\\/mcp\\/servers$/u, action: 'settings.write' },\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/mcp\\/repository\\/discover$/u,\n action: 'mcp.discover',\n },\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/mcp\\/repository\\/authorize$/u,\n action: 'mcp.authorize',\n },\n {\n method: 'DELETE',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/mcp\\/repository\\/authorize\\/[^/]+$/u,\n action: 'mcp.authorize',\n },\n // A key a plugin's MCP server asks for is a credential every session that loads it then sends.\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/mcp\\/repository\\/secrets$/u,\n action: 'mcp.authorize',\n },\n // Creating a session MCP client hands an outside app a credential into a live session, and\n // revoking one cuts an agent off mid-conversation. Both are gated like the repository revoke.\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/sessions\\/[^/]+\\/mcp\\/clients$/u,\n action: 'mcp.authorize',\n },\n {\n method: 'DELETE',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/sessions\\/[^/]+\\/mcp\\/clients\\/[^/]+$/u,\n action: 'mcp.authorize',\n },\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/sessions\\/[^/]+\\/plugins\\/computer-use\\/activate$/u,\n action: 'computer-use.activate',\n },\n { method: 'DELETE', pattern: /^\\/api\\/remote\\/trusted-devices\\/[^/]+$/u, action: 'device.revoke' },\n];\nexport function stepUpActionFor(method: string, path: string): StepUpAction | undefined {\n const wanted = method.toUpperCase();\n return GATED_ROUTES.find((route) => route.method === wanted && route.pattern.test(path))?.action;\n}\n\nexport function isStepUpAction(value: unknown): value is StepUpAction {\n return typeof value === 'string' && (STEP_UP_ACTIONS as readonly string[]).includes(value);\n}\n\nexport interface StoredCredential {\n /** Opaque handle for display and revocation. */\n id: string;\n /** The authenticator's credential id, base64url, as WebAuthn reports it. */\n credentialId: string;\n /** Base64url public key; the private half never leaves the device. */\n publicKey: string;\n /** Signature counter, for clone detection. */\n counter: number;\n transports: string[];\n label: string;\n createdAt: number;\n lastUsedAt: number;\n}\n\nexport type CounterVerdict = 'ok' | 'clone-suspected';\n\n/**\n * Whether a signature counter moved the way a real authenticator moves it.\n *\n * A counter that stays at zero means the authenticator does not implement one,\n * which is common and not a signal. A counter that goes backwards or repeats\n * while claiming to count means two things are signing with the same key, which\n * is the definition of a cloned credential.\n */\nexport function counterVerdict(stored: number, presented: number): CounterVerdict {\n if (stored === 0 && presented === 0) return 'ok';\n return presented > stored ? 'ok' : 'clone-suspected';\n}\n\n/** Whether a ceremony or step-up challenge is still live. */\nexport function challengeIsFresh(issuedAt: number, now: number, ttlMs: number): boolean {\n return now - issuedAt < ttlMs;\n}\n\n/** A quick tunnel's domain; its hostname rotates on every start. */\nconst ROTATING_SUFFIX = '.trycloudflare.com';\nexport function isQuickTunnelHost(origin: string | undefined): boolean {\n if (origin === undefined) return false;\n try {\n return new URL(origin).hostname.toLowerCase().endsWith(ROTATING_SUFFIX);\n } catch {\n return false;\n }\n}\n/** Dotted-quad, and the bracketed form a URL uses for v6. */\nconst IPV4 = /^\\d{1,3}(?:\\.\\d{1,3}){3}$/u;\n\n/**\n * The relying party id a passkey is bound to.\n *\n * Derived from the configured tunnel hostname and nothing else, never from a\n * request header: `rpID` is the entire scope of a credential, so a caller who\n * could influence it could mint credentials against somebody else's origin.\n *\n * Three things are refused rather than accepted and regretted later:\n *\n * - A quick tunnel, whose hostname rotates on every start, so a passkey\n * registered now would silently stop working on the next one.\n * - An IP address, which WebAuthn does not accept as a relying party id at all;\n * registering against one fails in the browser rather than here, which is a\n * much worse place to find out.\n * - Anything without a dot, which cannot be a public tunnel hostname.\n */\nexport function relyingPartyId(publicOrigin: string | undefined): string | undefined {\n if (publicOrigin === undefined) return undefined;\n let host: string;\n try {\n host = new URL(publicOrigin).hostname.toLowerCase();\n } catch {\n return undefined;\n }\n if (isQuickTunnelHost(publicOrigin)) return undefined;\n if (IPV4.test(host) || host.startsWith('[')) return undefined;\n if (!host.includes('.')) return undefined;\n return host;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CACA;AACF;;AAKA,MAAa,2BAA2B;;AAExC,MAAa,kBAAkB;;;;;;;;;AAU/B,MAAM,eAAqF;CACzF;EAAE,QAAQ;EAAQ,SAAS;EAAoE,QAAQ;CAAY;CACnH;EAAE,QAAQ;EAAQ,SAAS;EAA4C,QAAQ;CAAiB;CAChG;EAAE,QAAQ;EAAU,SAAS;EAAmD,QAAQ;CAAiB;CACzG;EAAE,QAAQ;EAAQ,SAAS;EAAwB,QAAQ;CAAiB;CAC5E;EACE,QAAQ;EAGR,SAAS;EACT,QAAQ;CACV;CAEA;EAAE,QAAQ;EAAQ,SAAS;EAAuD,QAAQ;CAAiB;CAE3G;EAAE,QAAQ;EAAS,SAAS;EAA+B,QAAQ;CAAiB;CAEpF;EAAE,QAAQ;EAAO,SAAS;EAAmD,QAAQ;CAAiB;CACtG;EAAE,QAAQ;EAAQ,SAAS;EAAqD,QAAQ;CAAiB;CACzG;EAAE,QAAQ;EAAU,SAAS;EAA2C,QAAQ;CAAkB;CAElG;EACE,QAAQ;EACR,SACE;EACF,QAAQ;CACV;CAEA;EAAE,QAAQ;EAAQ,SAAS;EAA2D,QAAQ;CAAiB;CAC/G;EAAE,QAAQ;EAAS,SAAS;EAA2D,QAAQ;CAAiB;CAChH;EAAE,QAAQ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C,CAAC,SAAS,YAAY;CACpD,QAAQ;EACN;CACF;CACA,IAAI,kBAAkB,YAAY,GAAG,OAAO,KAAA;CAC5C,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,WAAW,GAAG,GAAG,OAAO,KAAA;CACpD,IAAI,CAAC,KAAK,SAAS,GAAG,GAAG,OAAO,KAAA;CAChC,OAAO;AACT"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/services/webauthnPolicy/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;qBAuBa;YAcD,uBAAuB;iBAyFlB;;EAEf;;EAEA;;EAEA;;EAEA;EACA;EACA;EACA;EACA"}
1
+ {"version":3,"file":"index.d.mts","names":[],"sources":["../../../../src/services/webauthnPolicy/index.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;qBAuBa;YAcD,uBAAuB;iBA+FlB;;EAEf;;EAEA;;EAEA;;EAEA;EACA;EACA;EACA;EACA"}
@@ -130,6 +130,11 @@ const GATED_ROUTES = [
130
130
  pattern: /^\/api\/workspaces\/[^/]+\/plugins\/mcp\/repository\/authorize\/[^/]+$/u,
131
131
  action: "mcp.authorize"
132
132
  },
133
+ {
134
+ method: "POST",
135
+ pattern: /^\/api\/workspaces\/[^/]+\/plugins\/mcp\/repository\/secrets$/u,
136
+ action: "mcp.authorize"
137
+ },
133
138
  {
134
139
  method: "POST",
135
140
  pattern: /^\/api\/workspaces\/[^/]+\/sessions\/[^/]+\/mcp\/clients$/u,
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/services/webauthnPolicy/index.ts"],"sourcesContent":["/**\n * What a passkey is allowed to prove, and for how long.\n *\n * A session cookie is a bearer token: whoever holds the bytes is you. A passkey\n * is a private key in the device's secure enclave that never leaves it, so the\n * cookie stops being the only thing between a stolen phone and this machine.\n * The cookie does not go away, because a WebSocket cannot run a ceremony per\n * frame; what changes is that the cookie is short-lived, re-mintable with a\n * gesture rather than a QR, and insufficient on its own for the actions below.\n *\n * The crypto lives in the adapter. This file is the policy: which actions need\n * a fresh signature, how long a challenge is good for, and when a counter says\n * the credential has been cloned.\n */\n\n/**\n * Actions that need a fresh gesture even from a live session.\n *\n * These are escalation paths rather than ordinary prompting or tool approval:\n * credentials redirect machine traffic, sessions run code in a selected directory,\n * repository writes change future sessions, and live MCP operations may start local\n * processes or contact remote servers.\n */\nexport const STEP_UP_ACTIONS = [\n 'provider.login',\n 'provider.logout',\n 'session.create',\n 'settings.write',\n 'mcp.discover',\n 'mcp.authorize',\n 'computer-use.activate',\n // Revoking a trusted native device ends every session it holds; from a remote caller it needs a\n // fresh gesture so a stolen cookie cannot lock the owner's phone out.\n 'device.revoke',\n 'peer.link',\n] as const;\n\nexport type StepUpAction = (typeof STEP_UP_ACTIONS)[number];\n\n/** Short enough that a captured challenge is useless, long enough for a slow Face ID. */\nexport const STEP_UP_CHALLENGE_TTL_MS = 60_000;\n/** A registration or sign-in ceremony the user has to complete. */\nexport const CEREMONY_TTL_MS = 120_000;\n\n/**\n * Which action, if any, a request is attempting.\n *\n * Matched here rather than at each route so the list of gated operations is one\n * readable table instead of three call sites that can drift apart. Anything not\n * named is not gated, which is the safe default only because the gate is an\n * addition to the session check rather than a replacement for it.\n */\nconst GATED_ROUTES: readonly { method: string; pattern: RegExp; action: StepUpAction }[] = [\n { method: 'POST', pattern: /^\\/api\\/plugins\\/session-peer\\/link\\/(?:prepare|accept|unlink)$/u, action: 'peer.link' },\n { method: 'POST', pattern: /^\\/api\\/plugins\\/marketplace\\/installs$/u, action: 'settings.write' },\n { method: 'DELETE', pattern: /^\\/api\\/plugins\\/marketplace\\/installs\\/[^/]+$/u, action: 'settings.write' },\n { method: 'POST', pattern: /^\\/api\\/workspaces$/u, action: 'session.create' },\n {\n method: 'POST',\n // Reviving a recorded session starts an agent in a directory, so it is gated\n // exactly as creating one is.\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/(?:resume|sessions(?:\\/[^/]+\\/(?:resume|revive))?)$/u,\n action: 'session.create',\n },\n // The git new-session dialog starts a worktree session, which runs code in a directory.\n { method: 'POST', pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/git\\/sessions$/u, action: 'session.create' },\n // Choosing a workspace's sandbox changes where its sessions run code.\n { method: 'PATCH', pattern: /^\\/api\\/workspaces\\/[^/]+$/u, action: 'settings.write' },\n // A workspace's git remote credentials redirect what the cockpit pushes and where its token goes.\n { method: 'PUT', pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/git\\/auth$/u, action: 'settings.write' },\n { method: 'POST', pattern: /^\\/api\\/plugins\\/po\\/logins(?:\\/[^/]+\\/answer)?$/u, action: 'provider.login' },\n { method: 'DELETE', pattern: /^\\/api\\/plugins\\/po\\/providers\\/[^/]+$/u, action: 'provider.logout' },\n // The default preset decides which Po plugins every new session loads.\n {\n method: 'PUT',\n pattern:\n /^\\/api(?:\\/workspaces\\/[^/]+)?\\/settings\\/(?:value|repository\\/selection|images|presets(?:\\/(?:create|rename|delete|add-layer|remove-layer))?)$/u,\n action: 'settings.write',\n },\n // Saved MCP configuration changes affect future sessions, like other settings writes.\n { method: 'POST', pattern: /^\\/api(?:\\/workspaces\\/[^/]+)?\\/plugins\\/mcp\\/servers$/u, action: 'settings.write' },\n { method: 'PATCH', pattern: /^\\/api(?:\\/workspaces\\/[^/]+)?\\/plugins\\/mcp\\/servers$/u, action: 'settings.write' },\n { method: 'DELETE', pattern: /^\\/api(?:\\/workspaces\\/[^/]+)?\\/plugins\\/mcp\\/servers$/u, action: 'settings.write' },\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/mcp\\/repository\\/discover$/u,\n action: 'mcp.discover',\n },\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/mcp\\/repository\\/authorize$/u,\n action: 'mcp.authorize',\n },\n {\n method: 'DELETE',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/mcp\\/repository\\/authorize\\/[^/]+$/u,\n action: 'mcp.authorize',\n },\n // Creating a session MCP client hands an outside app a credential into a live session, and\n // revoking one cuts an agent off mid-conversation. Both are gated like the repository revoke.\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/sessions\\/[^/]+\\/mcp\\/clients$/u,\n action: 'mcp.authorize',\n },\n {\n method: 'DELETE',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/sessions\\/[^/]+\\/mcp\\/clients\\/[^/]+$/u,\n action: 'mcp.authorize',\n },\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/sessions\\/[^/]+\\/plugins\\/computer-use\\/activate$/u,\n action: 'computer-use.activate',\n },\n { method: 'DELETE', pattern: /^\\/api\\/remote\\/trusted-devices\\/[^/]+$/u, action: 'device.revoke' },\n];\nexport function stepUpActionFor(method: string, path: string): StepUpAction | undefined {\n const wanted = method.toUpperCase();\n return GATED_ROUTES.find((route) => route.method === wanted && route.pattern.test(path))?.action;\n}\n\nexport function isStepUpAction(value: unknown): value is StepUpAction {\n return typeof value === 'string' && (STEP_UP_ACTIONS as readonly string[]).includes(value);\n}\n\nexport interface StoredCredential {\n /** Opaque handle for display and revocation. */\n id: string;\n /** The authenticator's credential id, base64url, as WebAuthn reports it. */\n credentialId: string;\n /** Base64url public key; the private half never leaves the device. */\n publicKey: string;\n /** Signature counter, for clone detection. */\n counter: number;\n transports: string[];\n label: string;\n createdAt: number;\n lastUsedAt: number;\n}\n\nexport type CounterVerdict = 'ok' | 'clone-suspected';\n\n/**\n * Whether a signature counter moved the way a real authenticator moves it.\n *\n * A counter that stays at zero means the authenticator does not implement one,\n * which is common and not a signal. A counter that goes backwards or repeats\n * while claiming to count means two things are signing with the same key, which\n * is the definition of a cloned credential.\n */\nexport function counterVerdict(stored: number, presented: number): CounterVerdict {\n if (stored === 0 && presented === 0) return 'ok';\n return presented > stored ? 'ok' : 'clone-suspected';\n}\n\n/** Whether a ceremony or step-up challenge is still live. */\nexport function challengeIsFresh(issuedAt: number, now: number, ttlMs: number): boolean {\n return now - issuedAt < ttlMs;\n}\n\n/** A quick tunnel's domain; its hostname rotates on every start. */\nconst ROTATING_SUFFIX = '.trycloudflare.com';\nexport function isQuickTunnelHost(origin: string | undefined): boolean {\n if (origin === undefined) return false;\n try {\n return new URL(origin).hostname.toLowerCase().endsWith(ROTATING_SUFFIX);\n } catch {\n return false;\n }\n}\n/** Dotted-quad, and the bracketed form a URL uses for v6. */\nconst IPV4 = /^\\d{1,3}(?:\\.\\d{1,3}){3}$/u;\n\n/**\n * The relying party id a passkey is bound to.\n *\n * Derived from the configured tunnel hostname and nothing else, never from a\n * request header: `rpID` is the entire scope of a credential, so a caller who\n * could influence it could mint credentials against somebody else's origin.\n *\n * Three things are refused rather than accepted and regretted later:\n *\n * - A quick tunnel, whose hostname rotates on every start, so a passkey\n * registered now would silently stop working on the next one.\n * - An IP address, which WebAuthn does not accept as a relying party id at all;\n * registering against one fails in the browser rather than here, which is a\n * much worse place to find out.\n * - Anything without a dot, which cannot be a public tunnel hostname.\n */\nexport function relyingPartyId(publicOrigin: string | undefined): string | undefined {\n if (publicOrigin === undefined) return undefined;\n let host: string;\n try {\n host = new URL(publicOrigin).hostname.toLowerCase();\n } catch {\n return undefined;\n }\n if (isQuickTunnelHost(publicOrigin)) return undefined;\n if (IPV4.test(host) || host.startsWith('[')) return undefined;\n if (!host.includes('.')) return undefined;\n return host;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CACA;AACF;;AAKA,MAAa,2BAA2B;;AAExC,MAAa,kBAAkB;;;;;;;;;AAU/B,MAAM,eAAqF;CACzF;EAAE,QAAQ;EAAQ,SAAS;EAAoE,QAAQ;CAAY;CACnH;EAAE,QAAQ;EAAQ,SAAS;EAA4C,QAAQ;CAAiB;CAChG;EAAE,QAAQ;EAAU,SAAS;EAAmD,QAAQ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AAc,GAAG,OAAO;CAC5C,OAAO,YAAY,SAAS,OAAO;AACrC;;AAGA,SAAgB,iBAAiB,UAAkB,KAAa,OAAwB;CACtF,OAAO,MAAM,WAAW;AAC1B;;AAGA,MAAM,kBAAkB;AACxB,SAAgB,kBAAkB,QAAqC;CACrE,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,IAAI;EACF,OAAO,IAAI,IAAI,MAAM,CAAC,CAAC,SAAS,YAAY,CAAC,CAAC,SAAS,eAAe;CACxE,QAAQ;EACN,OAAO;CACT;AACF;;AAEA,MAAM,OAAO;;;;;;;;;;;;;;;;;AAkBb,SAAgB,eAAe,cAAsD;CACnF,IAAI,iBAAiB,KAAA,GAAW,OAAO,KAAA;CACvC,IAAI;CACJ,IAAI;EACF,OAAO,IAAI,IAAI,YAAY,CAAC,CAAC,SAAS,YAAY;CACpD,QAAQ;EACN;CACF;CACA,IAAI,kBAAkB,YAAY,GAAG,OAAO,KAAA;CAC5C,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,WAAW,GAAG,GAAG,OAAO,KAAA;CACpD,IAAI,CAAC,KAAK,SAAS,GAAG,GAAG,OAAO,KAAA;CAChC,OAAO;AACT"}
1
+ {"version":3,"file":"index.mjs","names":[],"sources":["../../../../src/services/webauthnPolicy/index.ts"],"sourcesContent":["/**\n * What a passkey is allowed to prove, and for how long.\n *\n * A session cookie is a bearer token: whoever holds the bytes is you. A passkey\n * is a private key in the device's secure enclave that never leaves it, so the\n * cookie stops being the only thing between a stolen phone and this machine.\n * The cookie does not go away, because a WebSocket cannot run a ceremony per\n * frame; what changes is that the cookie is short-lived, re-mintable with a\n * gesture rather than a QR, and insufficient on its own for the actions below.\n *\n * The crypto lives in the adapter. This file is the policy: which actions need\n * a fresh signature, how long a challenge is good for, and when a counter says\n * the credential has been cloned.\n */\n\n/**\n * Actions that need a fresh gesture even from a live session.\n *\n * These are escalation paths rather than ordinary prompting or tool approval:\n * credentials redirect machine traffic, sessions run code in a selected directory,\n * repository writes change future sessions, and live MCP operations may start local\n * processes or contact remote servers.\n */\nexport const STEP_UP_ACTIONS = [\n 'provider.login',\n 'provider.logout',\n 'session.create',\n 'settings.write',\n 'mcp.discover',\n 'mcp.authorize',\n 'computer-use.activate',\n // Revoking a trusted native device ends every session it holds; from a remote caller it needs a\n // fresh gesture so a stolen cookie cannot lock the owner's phone out.\n 'device.revoke',\n 'peer.link',\n] as const;\n\nexport type StepUpAction = (typeof STEP_UP_ACTIONS)[number];\n\n/** Short enough that a captured challenge is useless, long enough for a slow Face ID. */\nexport const STEP_UP_CHALLENGE_TTL_MS = 60_000;\n/** A registration or sign-in ceremony the user has to complete. */\nexport const CEREMONY_TTL_MS = 120_000;\n\n/**\n * Which action, if any, a request is attempting.\n *\n * Matched here rather than at each route so the list of gated operations is one\n * readable table instead of three call sites that can drift apart. Anything not\n * named is not gated, which is the safe default only because the gate is an\n * addition to the session check rather than a replacement for it.\n */\nconst GATED_ROUTES: readonly { method: string; pattern: RegExp; action: StepUpAction }[] = [\n { method: 'POST', pattern: /^\\/api\\/plugins\\/session-peer\\/link\\/(?:prepare|accept|unlink)$/u, action: 'peer.link' },\n { method: 'POST', pattern: /^\\/api\\/plugins\\/marketplace\\/installs$/u, action: 'settings.write' },\n { method: 'DELETE', pattern: /^\\/api\\/plugins\\/marketplace\\/installs\\/[^/]+$/u, action: 'settings.write' },\n { method: 'POST', pattern: /^\\/api\\/workspaces$/u, action: 'session.create' },\n {\n method: 'POST',\n // Reviving a recorded session starts an agent in a directory, so it is gated\n // exactly as creating one is.\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/(?:resume|sessions(?:\\/[^/]+\\/(?:resume|revive))?)$/u,\n action: 'session.create',\n },\n // The git new-session dialog starts a worktree session, which runs code in a directory.\n { method: 'POST', pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/git\\/sessions$/u, action: 'session.create' },\n // Choosing a workspace's sandbox changes where its sessions run code.\n { method: 'PATCH', pattern: /^\\/api\\/workspaces\\/[^/]+$/u, action: 'settings.write' },\n // A workspace's git remote credentials redirect what the cockpit pushes and where its token goes.\n { method: 'PUT', pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/git\\/auth$/u, action: 'settings.write' },\n { method: 'POST', pattern: /^\\/api\\/plugins\\/po\\/logins(?:\\/[^/]+\\/answer)?$/u, action: 'provider.login' },\n { method: 'DELETE', pattern: /^\\/api\\/plugins\\/po\\/providers\\/[^/]+$/u, action: 'provider.logout' },\n // The default preset decides which Po plugins every new session loads.\n {\n method: 'PUT',\n pattern:\n /^\\/api(?:\\/workspaces\\/[^/]+)?\\/settings\\/(?:value|repository\\/selection|images|presets(?:\\/(?:create|rename|delete|add-layer|remove-layer))?)$/u,\n action: 'settings.write',\n },\n // Saved MCP configuration changes affect future sessions, like other settings writes.\n { method: 'POST', pattern: /^\\/api(?:\\/workspaces\\/[^/]+)?\\/plugins\\/mcp\\/servers$/u, action: 'settings.write' },\n { method: 'PATCH', pattern: /^\\/api(?:\\/workspaces\\/[^/]+)?\\/plugins\\/mcp\\/servers$/u, action: 'settings.write' },\n { method: 'DELETE', pattern: /^\\/api(?:\\/workspaces\\/[^/]+)?\\/plugins\\/mcp\\/servers$/u, action: 'settings.write' },\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/mcp\\/repository\\/discover$/u,\n action: 'mcp.discover',\n },\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/mcp\\/repository\\/authorize$/u,\n action: 'mcp.authorize',\n },\n {\n method: 'DELETE',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/mcp\\/repository\\/authorize\\/[^/]+$/u,\n action: 'mcp.authorize',\n },\n // A key a plugin's MCP server asks for is a credential every session that loads it then sends.\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/plugins\\/mcp\\/repository\\/secrets$/u,\n action: 'mcp.authorize',\n },\n // Creating a session MCP client hands an outside app a credential into a live session, and\n // revoking one cuts an agent off mid-conversation. Both are gated like the repository revoke.\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/sessions\\/[^/]+\\/mcp\\/clients$/u,\n action: 'mcp.authorize',\n },\n {\n method: 'DELETE',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/sessions\\/[^/]+\\/mcp\\/clients\\/[^/]+$/u,\n action: 'mcp.authorize',\n },\n {\n method: 'POST',\n pattern: /^\\/api\\/workspaces\\/[^/]+\\/sessions\\/[^/]+\\/plugins\\/computer-use\\/activate$/u,\n action: 'computer-use.activate',\n },\n { method: 'DELETE', pattern: /^\\/api\\/remote\\/trusted-devices\\/[^/]+$/u, action: 'device.revoke' },\n];\nexport function stepUpActionFor(method: string, path: string): StepUpAction | undefined {\n const wanted = method.toUpperCase();\n return GATED_ROUTES.find((route) => route.method === wanted && route.pattern.test(path))?.action;\n}\n\nexport function isStepUpAction(value: unknown): value is StepUpAction {\n return typeof value === 'string' && (STEP_UP_ACTIONS as readonly string[]).includes(value);\n}\n\nexport interface StoredCredential {\n /** Opaque handle for display and revocation. */\n id: string;\n /** The authenticator's credential id, base64url, as WebAuthn reports it. */\n credentialId: string;\n /** Base64url public key; the private half never leaves the device. */\n publicKey: string;\n /** Signature counter, for clone detection. */\n counter: number;\n transports: string[];\n label: string;\n createdAt: number;\n lastUsedAt: number;\n}\n\nexport type CounterVerdict = 'ok' | 'clone-suspected';\n\n/**\n * Whether a signature counter moved the way a real authenticator moves it.\n *\n * A counter that stays at zero means the authenticator does not implement one,\n * which is common and not a signal. A counter that goes backwards or repeats\n * while claiming to count means two things are signing with the same key, which\n * is the definition of a cloned credential.\n */\nexport function counterVerdict(stored: number, presented: number): CounterVerdict {\n if (stored === 0 && presented === 0) return 'ok';\n return presented > stored ? 'ok' : 'clone-suspected';\n}\n\n/** Whether a ceremony or step-up challenge is still live. */\nexport function challengeIsFresh(issuedAt: number, now: number, ttlMs: number): boolean {\n return now - issuedAt < ttlMs;\n}\n\n/** A quick tunnel's domain; its hostname rotates on every start. */\nconst ROTATING_SUFFIX = '.trycloudflare.com';\nexport function isQuickTunnelHost(origin: string | undefined): boolean {\n if (origin === undefined) return false;\n try {\n return new URL(origin).hostname.toLowerCase().endsWith(ROTATING_SUFFIX);\n } catch {\n return false;\n }\n}\n/** Dotted-quad, and the bracketed form a URL uses for v6. */\nconst IPV4 = /^\\d{1,3}(?:\\.\\d{1,3}){3}$/u;\n\n/**\n * The relying party id a passkey is bound to.\n *\n * Derived from the configured tunnel hostname and nothing else, never from a\n * request header: `rpID` is the entire scope of a credential, so a caller who\n * could influence it could mint credentials against somebody else's origin.\n *\n * Three things are refused rather than accepted and regretted later:\n *\n * - A quick tunnel, whose hostname rotates on every start, so a passkey\n * registered now would silently stop working on the next one.\n * - An IP address, which WebAuthn does not accept as a relying party id at all;\n * registering against one fails in the browser rather than here, which is a\n * much worse place to find out.\n * - Anything without a dot, which cannot be a public tunnel hostname.\n */\nexport function relyingPartyId(publicOrigin: string | undefined): string | undefined {\n if (publicOrigin === undefined) return undefined;\n let host: string;\n try {\n host = new URL(publicOrigin).hostname.toLowerCase();\n } catch {\n return undefined;\n }\n if (isQuickTunnelHost(publicOrigin)) return undefined;\n if (IPV4.test(host) || host.startsWith('[')) return undefined;\n if (!host.includes('.')) return undefined;\n return host;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAuBA,MAAa,kBAAkB;CAC7B;CACA;CACA;CACA;CACA;CACA;CACA;CAGA;CACA;AACF;;AAKA,MAAa,2BAA2B;;AAExC,MAAa,kBAAkB;;;;;;;;;AAU/B,MAAM,eAAqF;CACzF;EAAE,QAAQ;EAAQ,SAAS;EAAoE,QAAQ;CAAY;CACnH;EAAE,QAAQ;EAAQ,SAAS;EAA4C,QAAQ;CAAiB;CAChG;EAAE,QAAQ;EAAU,SAAS;EAAmD,QAAQ;CAAiB;CACzG;EAAE,QAAQ;EAAQ,SAAS;EAAwB,QAAQ;CAAiB;CAC5E;E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AO,YAAY,SAAS,OAAO;AACrC;;AAGA,SAAgB,iBAAiB,UAAkB,KAAa,OAAwB;CACtF,OAAO,MAAM,WAAW;AAC1B;;AAGA,MAAM,kBAAkB;AACxB,SAAgB,kBAAkB,QAAqC;CACrE,IAAI,WAAW,KAAA,GAAW,OAAO;CACjC,IAAI;EACF,OAAO,IAAI,IAAI,MAAM,CAAC,CAAC,SAAS,YAAY,CAAC,CAAC,SAAS,eAAe;CACxE,QAAQ;EACN,OAAO;CACT;AACF;;AAEA,MAAM,OAAO;;;;;;;;;;;;;;;;;AAkBb,SAAgB,eAAe,cAAsD;CACnF,IAAI,iBAAiB,KAAA,GAAW,OAAO,KAAA;CACvC,IAAI;CACJ,IAAI;EACF,OAAO,IAAI,IAAI,YAAY,CAAC,CAAC,SAAS,YAAY;CACpD,QAAQ;EACN;CACF;CACA,IAAI,kBAAkB,YAAY,GAAG,OAAO,KAAA;CAC5C,IAAI,KAAK,KAAK,IAAI,KAAK,KAAK,WAAW,GAAG,GAAG,OAAO,KAAA;CACpD,IAAI,CAAC,KAAK,SAAS,GAAG,GAAG,OAAO,KAAA;CAChC,OAAO;AACT"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agimon-ai/po-core",
3
- "version": "0.0.0-alpha.151",
3
+ "version": "0.0.0-alpha.152",
4
4
  "description": "Po runtime systems and reusable core services.",
5
5
  "keywords": [
6
6
  "ai",
@@ -619,8 +619,8 @@
619
619
  "registry": "https://registry.npmjs.org/"
620
620
  },
621
621
  "dependencies": {
622
- "@agimon-ai/po-logsink": "0.0.1-alpha.133",
623
- "@agimon-ai/po-web-security": "0.0.0-alpha.151",
622
+ "@agimon-ai/po-logsink": "0.0.1-alpha.134",
623
+ "@agimon-ai/po-web-security": "0.0.0-alpha.152",
624
624
  "@deepseek-ai/cordis": "4.0.5",
625
625
  "@earendil-works/chord": "1.5.1",
626
626
  "@earendil-works/pi-agent-core": "1.5.1",
@@ -646,7 +646,7 @@
646
646
  "yaml": "2.9.1"
647
647
  },
648
648
  "devDependencies": {
649
- "@agimon-ai/vibe-lint-plugin-po-core": "0.0.0-alpha.151",
649
+ "@agimon-ai/vibe-lint-plugin-po-core": "0.0.0-alpha.152",
650
650
  "@apidevtools/swagger-parser": "^13.1.0",
651
651
  "@asyncapi/parser": "^3.6.4",
652
652
  "@earendil-works/pi-ai": "1.5.1",