@plurnk/plurnk-contracts 9.0.0 → 10.0.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/.env.defaults +1 -19
- package/README.md +5 -6
- package/SPEC.md +93 -44
- package/dist/schema/DaemonNotificationEnvelope.json +77 -30
- package/dist/schema/FunctionalityCandidate.json +4 -0
- package/dist/schema/FunctionalityDiscoverQuery.json +12 -0
- package/dist/schema/FunctionalityDiscoverResult.json +10 -0
- package/dist/schema/FunctionalityListQuery.json +33 -0
- package/dist/schema/FunctionalityListResult.json +16 -1
- package/dist/schema/ModelCatalogPage.json +9 -0
- package/dist/schema/PlurnkStatement.json +18 -2
- package/dist/schema/ProviderAccounting.json +3 -3
- package/dist/schema/ProviderCost.json +1 -1
- package/dist/schema/ProviderRequestAccounting.json +3 -3
- package/dist/schema/ProviderUsage.json +1 -1
- package/dist/src/ActorIdentity.d.ts +26 -0
- package/dist/src/ActorIdentity.d.ts.map +1 -0
- package/dist/src/ActorIdentity.js +179 -0
- package/dist/src/ActorIdentity.js.map +1 -0
- package/dist/src/Application.d.ts +38 -126
- package/dist/src/Application.d.ts.map +1 -1
- package/dist/src/Application.js +47 -220
- package/dist/src/Application.js.map +1 -1
- package/dist/src/ApplicationNotifications.d.ts +19 -6
- package/dist/src/ApplicationNotifications.d.ts.map +1 -1
- package/dist/src/ApplicationNotifications.js +6 -3
- package/dist/src/ApplicationNotifications.js.map +1 -1
- package/dist/src/ApplicationPort.d.ts +27 -6
- package/dist/src/ApplicationPort.d.ts.map +1 -1
- package/dist/src/ApplicationPort.js +1 -1
- package/dist/src/ApplicationPort.js.map +1 -1
- package/dist/src/ApplicationStream.d.ts +2 -2
- package/dist/src/ApplicationStream.d.ts.map +1 -1
- package/dist/src/ApplicationStream.js.map +1 -1
- package/dist/src/CollectionCommand.d.ts +33 -0
- package/dist/src/CollectionCommand.d.ts.map +1 -0
- package/dist/src/CollectionCommand.js +277 -0
- package/dist/src/CollectionCommand.js.map +1 -0
- package/dist/src/Functionality.d.ts +7 -2
- package/dist/src/Functionality.d.ts.map +1 -1
- package/dist/src/Functionality.js.map +1 -1
- package/dist/src/HttpOrigin.d.ts +79 -10
- package/dist/src/HttpOrigin.d.ts.map +1 -1
- package/dist/src/HttpOrigin.js +286 -44
- package/dist/src/HttpOrigin.js.map +1 -1
- package/dist/src/HttpPort.d.ts +35 -0
- package/dist/src/HttpPort.d.ts.map +1 -0
- package/dist/src/HttpPort.js +106 -0
- package/dist/src/HttpPort.js.map +1 -0
- package/dist/src/InteractiveCommands.d.ts +96 -0
- package/dist/src/InteractiveCommands.d.ts.map +1 -0
- package/dist/src/InteractiveCommands.js +409 -0
- package/dist/src/InteractiveCommands.js.map +1 -0
- package/dist/src/McpWireTool.d.ts +27 -0
- package/dist/src/McpWireTool.d.ts.map +1 -0
- package/dist/src/McpWireTool.js +30 -0
- package/dist/src/McpWireTool.js.map +1 -0
- package/dist/src/OAuthClient.d.ts +64 -0
- package/dist/src/OAuthClient.d.ts.map +1 -0
- package/dist/src/OAuthClient.js +226 -0
- package/dist/src/OAuthClient.js.map +1 -0
- package/dist/src/ScheduleCommand.d.ts +60 -0
- package/dist/src/ScheduleCommand.d.ts.map +1 -0
- package/dist/src/ScheduleCommand.js +677 -0
- package/dist/src/ScheduleCommand.js.map +1 -0
- package/dist/src/SessionProjection.d.ts +91 -0
- package/dist/src/SessionProjection.d.ts.map +1 -0
- package/dist/src/SessionProjection.js +223 -0
- package/dist/src/SessionProjection.js.map +1 -0
- package/dist/src/Validator.d.ts +2 -1
- package/dist/src/Validator.d.ts.map +1 -1
- package/dist/src/Validator.js +19 -1
- package/dist/src/Validator.js.map +1 -1
- package/dist/src/index.d.ts +10 -3
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +7 -1
- package/dist/src/index.js.map +1 -1
- package/dist/src/types.generated.d.ts +85 -21
- package/dist/src/types.generated.d.ts.map +1 -1
- package/dist/src/types.generated.js.map +1 -1
- package/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ations} {§client-interactive-commands} {§client-composer-sigils}\n// Browser/Node-neutral interactive client command inventory, composer sigil classifier,\n// inline skill prompt-block builder, and multi-token completion state machine.\n\nimport { PLURNK_OPS, PROPOSAL_POLICIES } from \"./types.ts\";\nimport {\n FAMILY_DISCOVER_FLAGS_BY_FAMILY,\n FAMILY_LIST_FLAGS,\n LIST_ORIGINS,\n LIST_STATES,\n MODELS_LIST_FLAGS,\n} from \"./CollectionCommand.ts\";\nimport { SCHEDULE_ADD_FLAGS } from \"./ScheduleCommand.ts\";\n\nexport interface InteractiveCommandSpec {\n readonly name: string;\n readonly usage: string;\n readonly summary: string;\n readonly settingsSection?: string;\n readonly clientOnly?: \"term\" | \"web\";\n}\n\nexport interface FamilySubcommandSpec {\n readonly value: string;\n readonly description: string;\n}\n\nexport const INTERACTIVE_COMMANDS: readonly InteractiveCommandSpec[] = Object.freeze([\n { name: \"help\", usage: \"/help [verb]\", summary: \"Show the command index or one command's usage.\", settingsSection: \"help\" },\n { name: \"update\", usage: \"/update\", summary: \"Update the model catalog and show how to update Plurnk packages.\" },\n { name: \"models\", usage: \"/models [search] [--provider <id>] [--all] [--offset <n>] [--limit <n>]\", summary: \"Search the bounded model catalog.\", settingsSection: \"models\" },\n { name: \"workspaces\", usage: \"/workspaces\", summary: \"List daemon workspaces.\" },\n { name: \"sessions\", usage: \"/sessions\", summary: \"List this workspace's sessions as a tree, each with its state.\" },\n { name: \"loops\", usage: \"/loops\", summary: \"List this session's loops: each one's number and opening line.\" },\n { name: \"loop\", usage: \"/loop [n]\", summary: \"Print loop n whole, or the current loop.\" },\n { name: \"model\", usage: \"/model [selector] [effort]\", summary: \"Inspect or select this session's durable model, and its effort with it.\", settingsSection: \"session\" },\n { name: \"child\", usage: \"/child [selector|inherit]\", summary: \"Inspect or select the inherited child model.\", settingsSection: \"session\" },\n { name: \"effort\", usage: \"/effort [policy]\", summary: \"Inspect or select reasoning effort.\", settingsSection: \"session\" },\n { name: \"persona\", usage: \"/persona [name|none]\", summary: \"Inspect, select, or clear this session's persona role.\", settingsSection: \"session\" },\n { name: \"mode\", usage: \"/mode [review|accept|reject]\", summary: \"Inspect or select this session's proposal review mode.\", settingsSection: \"session\" },\n { name: \"yolo\", usage: \"/yolo\", summary: \"Toggle proposal auto-accept (Shift-Tab).\" },\n { name: \"workspace\", usage: \"/workspace [name]\", summary: \"Open or create a workspace.\", settingsSection: \"workspace\" },\n { name: \"rename\", usage: \"/rename <name>\", summary: \"Rename this workspace's mutable handle.\", settingsSection: \"workspace\" },\n { name: \"share\", usage: \"/share <folder>\", summary: \"Write this workspace's share into <folder> for a bug report.\" },\n { name: \"rollback\", usage: \"/rollback <loop>/<turn>/<item>\", summary: \"Reverse the bound session's file mutations after a log coordinate, latest first, as your own operations.\" },\n { name: \"session\", usage: \"/session [name]\", summary: \"Show this session, or go to the named one; a new name makes a new session.\", settingsSection: \"session\" },\n { name: \"fork\", usage: \"/fork [name]\", summary: \"Fork this session into a child that keeps its history, and go there.\" },\n { name: \"parent\", usage: \"/parent\", summary: \"Hop to the bound session's parent (Alt-h).\" },\n { name: \"enter\", usage: \"/enter\", summary: \"Hop into the bound session's newest child (Alt-l).\" },\n { name: \"older\", usage: \"/older\", summary: \"Hop to the next older sibling session, wrapping (Alt-j).\" },\n { name: \"newer\", usage: \"/newer\", summary: \"Hop to the next newer sibling session, wrapping (Alt-k).\" },\n { name: \"mcp\", usage: \"/mcp [subcommand]\", summary: \"List or manage this workspace's MCP servers.\", settingsSection: \"mcp\" },\n { name: \"skills\", usage: \"/skills [subcommand]\", summary: \"List or manage this workspace's Agent Skills.\", settingsSection: \"skills\" },\n { name: \"members\", usage: \"/members [subcommand]\", summary: \"List or manage this workspace's file members.\", settingsSection: \"members\" },\n { name: \"env\", usage: \"/env [--scope session|workspace] [subcommand]\", summary: \"Manage session overrides or shared workspace environment defaults.\", settingsSection: \"env\" },\n { name: \"schedule\", usage: \"/schedule [subcommand]\", summary: \"List or manage this workspace's schedules and macros.\", settingsSection: \"schedule\" },\n { name: \"personas\", usage: \"/personas [subcommand]\", summary: \"List or manage this workspace's persona roles.\", settingsSection: \"personas\" },\n { name: \"import\", usage: \"/import <path>\", summary: \"Insert a local file into the composer.\", clientOnly: \"term\" },\n { name: \"script\", usage: \"/script <path>\", summary: \"Submit MCP expressions through op.exec.\", clientOnly: \"term\" },\n { name: \"editor\", usage: \"/editor\", summary: \"Compose the current value in $EDITOR.\", clientOnly: \"term\" },\n { name: \"review\", usage: \"/review\", summary: \"Inspect pending proposals or questions.\" },\n { name: \"approve\", usage: \"/approve @<id> [optionId]\", summary: \"Approve the identified proposal or gate.\" },\n { name: \"accept\", usage: \"/accept @<id> [optionId]\", summary: \"Accept the identified proposal or gate.\" },\n { name: \"reject\", usage: \"/reject @<id> [optionId]\", summary: \"Reject the identified proposal or gate.\" },\n { name: \"cancel\", usage: \"/cancel @<id>\", summary: \"Cancel the identified proposal or question.\" },\n { name: \"edit\", usage: \"/edit @<id> <body...>\", summary: \"Edit and accept the identified proposal.\" },\n { name: \"answer\", usage: \"/answer @<id> <json>\", summary: \"Answer the identified elicitation or question.\" },\n { name: \"login\", usage: \"/login\", summary: \"Sign in to the daemon through the browser and keep the grant.\", clientOnly: \"term\" },\n { name: \"logout\", usage: \"/logout\", summary: \"Forget the stored token for this daemon.\" },\n { name: \"learn\", usage: \"/learn [--scope project|plurnk] [instructions]\", summary: \"Distill reusable workflow from this session into a SKILL.md.\" },\n { name: \"stop\", usage: \"/stop\", summary: \"Cancel the running loop.\" },\n { name: \"quit\", usage: \"/quit\", summary: \"Exit the interactive client.\", clientOnly: \"term\" },\n]);\n\nexport const FAMILY_SUBCOMMANDS_BY_FAMILY: Readonly<Record<string, readonly FamilySubcommandSpec[]>> = Object.freeze({\n mcp: Object.freeze([\n { value: \"list\", description: \"List definitions\" },\n { value: \"discover\", description: \"Discover candidates\" },\n { value: \"add\", description: \"Add definition\" },\n { value: \"replace\", description: \"Replace definition\" },\n { value: \"enable\", description: \"Enable definition\" },\n { value: \"disable\", description: \"Disable definition\" },\n { value: \"remove\", description: \"Remove definition\" },\n { value: \"skills\", description: \"Inspect MCP server skills\" },\n { value: \"complete\", description: \"Complete MCP prompt or resource\" },\n { value: \"oauth\", description: \"Authorize MCP server\" },\n ]),\n skills: Object.freeze([\n { value: \"list\", description: \"List definitions\" },\n { value: \"discover\", description: \"Discover candidates\" },\n { value: \"add\", description: \"Add definition\" },\n { value: \"replace\", description: \"Replace definition\" },\n { value: \"enable\", description: \"Enable definition\" },\n { value: \"disable\", description: \"Disable definition\" },\n { value: \"remove\", description: \"Remove definition\" },\n ]),\n personas: Object.freeze([\n { value: \"list\", description: \"List definitions\" },\n { value: \"discover\", description: \"Discover candidates\" },\n { value: \"add\", description: \"Add definition\" },\n { value: \"replace\", description: \"Replace definition\" },\n { value: \"enable\", description: \"Enable definition\" },\n { value: \"disable\", description: \"Disable definition\" },\n { value: \"remove\", description: \"Remove definition\" },\n ]),\n members: Object.freeze([\n { value: \"list\", description: \"List definitions\" },\n { value: \"discover\", description: \"Discover candidates\" },\n { value: \"add\", description: \"Add definition\" },\n { value: \"enable\", description: \"Enable definition\" },\n { value: \"disable\", description: \"Disable definition\" },\n { value: \"remove\", description: \"Remove definition\" },\n ]),\n env: Object.freeze([\n { value: \"list\", description: \"List variables\" },\n { value: \"discover\", description: \"Discover variables\" },\n { value: \"add\", description: \"Add variable\" },\n { value: \"replace\", description: \"Replace variable\" },\n { value: \"set\", description: \"Set NAME=value\" },\n { value: \"unset\", description: \"Remove variable\" },\n { value: \"enable\", description: \"Enable variable\" },\n { value: \"disable\", description: \"Disable variable\" },\n { value: \"remove\", description: \"Remove variable\" },\n { value: \"import\", description: \"Import dotenv file\" },\n { value: \"--scope\", description: \"Select session or workspace scope\" },\n ]),\n schedule: Object.freeze([\n { value: \"list\", description: \"List schedules and macros\" },\n { value: \"show\", description: \"Inspect one schedule or macro\" },\n { value: \"inspect\", description: \"Inspect one schedule or macro\" },\n { value: \"discover\", description: \"Show clock or preview rule occurrences\" },\n { value: \"add\", description: \"Add a prompt schedule or macro\" },\n { value: \"replace\", description: \"Replace an existing schedule or macro\" },\n { value: \"run\", description: \"Trigger a schedule or macro now\" },\n { value: \"done\", description: \"Mark an obligation done\" },\n { value: \"reopen\", description: \"Reopen a completed obligation\" },\n { value: \"enable\", description: \"Enable a schedule\" },\n { value: \"disable\", description: \"Disable a schedule\" },\n { value: \"remove\", description: \"Remove a schedule\" },\n ]),\n});\n\nexport interface InteractiveCompletionItem {\n readonly value: string;\n readonly description: string;\n readonly trailingSpace: boolean;\n}\n\nexport interface InteractiveCompletionResult {\n readonly suggestions: readonly InteractiveCompletionItem[];\n readonly prefix: string;\n}\n\nexport interface InteractiveCompletionSnapshot {\n readonly surface?: \"term\" | \"web\";\n readonly projectRoot?: string | null;\n readonly models?: readonly string[];\n readonly efforts?: readonly string[];\n readonly effortsForModel?: (selector: string) => readonly string[] | null | undefined;\n readonly personas?: readonly string[];\n readonly familyAliases?: Readonly<Record<string, readonly string[]>>;\n readonly sessionNames?: readonly string[];\n readonly workspaceNames?: readonly string[];\n readonly pendingGateIds?: readonly string[];\n readonly loopSequences?: readonly string[];\n readonly skills?: readonly { readonly name: string; readonly description?: string }[];\n readonly advertisedCommands?: readonly { readonly name: string; readonly description?: string }[];\n readonly promptSuggestions?: readonly string[];\n}\n\nconst filterPrefix = (\n candidates: readonly string[],\n frag: string,\n describe: (value: string) => string,\n trailingSpace: (value: string) => boolean = () => false,\n): InteractiveCompletionResult => {\n const lower = frag.toLowerCase();\n const hits = candidates.filter((c) => c.toLowerCase().startsWith(lower));\n return {\n suggestions: hits.map((value) => ({\n value,\n description: describe(value),\n trailingSpace: trailingSpace(value),\n })),\n prefix: frag,\n };\n};\n\nexport const completeInteractiveCommand = (\n line: string,\n snapshot: InteractiveCompletionSnapshot = {},\n): InteractiveCompletionResult => {\n if (line.length === 0) {\n const prompts = snapshot.promptSuggestions ?? [];\n if (prompts.length === 0) return { suggestions: [], prefix: \"\" };\n return {\n suggestions: prompts.map((value) => ({\n value,\n description: \"suggested prompt\",\n trailingSpace: false,\n })),\n prefix: \"\",\n };\n }\n\n const surface = snapshot.surface ?? \"term\";\n const visibleCommands = INTERACTIVE_COMMANDS.filter((c) =>\n surface === \"web\" ? c.clientOnly !== \"term\" : c.clientOnly !== \"web\",\n );\n\n const rootMatch = /^\\/([-\\w:]*)$/u.exec(line);\n if (rootMatch !== null) {\n const typed = rootMatch[1].toLowerCase();\n const seen = new Set<string>();\n const merged: InteractiveCompletionItem[] = [];\n for (const c of visibleCommands) {\n if (!c.name.startsWith(typed)) continue;\n seen.add(c.name);\n merged.push({\n value: `/${c.name}`,\n description: c.summary,\n trailingSpace: c.usage.includes(\" \"),\n });\n }\n for (const adv of snapshot.advertisedCommands ?? []) {\n if (seen.has(adv.name) || !adv.name.toLowerCase().startsWith(typed)) continue;\n seen.add(adv.name);\n merged.push({\n value: `/${adv.name}`,\n description: adv.description ?? \"command\",\n trailingSpace: true,\n });\n }\n merged.sort((a, b) => (a.value === `/${typed}` ? 0 : 1) - (b.value === `/${typed}` ? 0 : 1));\n return { suggestions: merged, prefix: line };\n }\n\n const helpMatch = /^\\/help\\s+(\\w*)$/u.exec(line);\n if (helpMatch !== null) {\n const summaryByName = new Map(visibleCommands.map((c) => [c.name, c.summary]));\n return filterPrefix(\n [...summaryByName.keys()],\n helpMatch[1],\n (v) => summaryByName.get(v) ?? \"command\",\n );\n }\n\n const learnScopeMatch = /^\\/learn\\s+--scope(?:\\s+|=)(\\w*)$/u.exec(line);\n if (learnScopeMatch !== null) {\n const scopes = snapshot.projectRoot === null ? [\"plurnk\"] : [\"project\", \"plurnk\"];\n return filterPrefix(\n scopes,\n learnScopeMatch[1],\n (v) => (v === \"plurnk\" ? \"user-wide Plurnk skills\" : \"project .agents/skills\"),\n () => true,\n );\n }\n\n const learnFlagMatch = /^\\/learn\\s+(--\\w*)$/u.exec(line);\n if (learnFlagMatch !== null) {\n return filterPrefix([\"--scope\"], learnFlagMatch[1], () => \"skill target scope\", () => true);\n }\n\n const envScopeMatch = /^\\/env\\s+--scope(?:\\s+|=)(\\w*)$/u.exec(line);\n if (envScopeMatch !== null) {\n return filterPrefix(\n [\"session\", \"workspace\"],\n envScopeMatch[1],\n (v) => (v === \"workspace\" ? \"workspace environment defaults\" : \"session environment overrides\"),\n () => true,\n );\n }\n\n const familyMatch = /^\\/(mcp|skills|personas|members|env|schedule)\\s+(?:--scope(?:=|\\s+)(?:session|workspace)\\s+)?([-\\w]*)$/u.exec(line);\n if (familyMatch !== null) {\n const family = familyMatch[1];\n const subs = (FAMILY_SUBCOMMANDS_BY_FAMILY[family] ?? []).filter(\n (s) => !(surface === \"web\" && family === \"env\" && s.value === \"import\"),\n );\n const descBySub = new Map(subs.map((s) => [s.value, s.description]));\n return filterPrefix(\n subs.map((s) => s.value),\n familyMatch[2],\n (v) => descBySub.get(v) ?? \"subcommand\",\n (v) => v !== \"list\",\n );\n }\n\n const familyAliasMatch = /^\\/(mcp|skills|personas|members|env|schedule)\\s+(?:--scope(?:=|\\s+)(?:session|workspace)\\s+)?(show|inspect|replace|enable|disable|remove|unset|oauth|skills|run|done|reopen)\\s+(\\S*)$/u.exec(line);\n if (familyAliasMatch !== null) {\n const family = familyAliasMatch[1];\n const sub = familyAliasMatch[2];\n const validForFamily =\n ((sub !== \"show\" && sub !== \"inspect\") || family === \"schedule\")\n && (sub !== \"replace\" || family !== \"members\");\n if (validForFamily) {\n const aliases = snapshot.familyAliases?.[family] ?? [];\n return filterPrefix(\n aliases,\n familyAliasMatch[3],\n () => `${family} definition`,\n () => sub === \"replace\",\n );\n }\n }\n\n const familyListStateMatch = /^\\/(mcp|skills|personas|members|env|schedule)\\s+(?:--scope(?:=|\\s+)(?:session|workspace)\\s+)?(?:list\\s+)?(?:.*\\s+)?--state(?:\\s+|=)([-\\w]*)$/u.exec(line);\n if (familyListStateMatch !== null) {\n return filterPrefix(LIST_STATES, familyListStateMatch[2], () => \"definition state\", () => true);\n }\n\n const familyListOriginMatch = /^\\/(mcp|skills|personas|members|env|schedule)\\s+(?:--scope(?:=|\\s+)(?:session|workspace)\\s+)?(?:list\\s+)?(?:.*\\s+)?--origin(?:\\s+|=)([-\\w]*)$/u.exec(line);\n if (familyListOriginMatch !== null) {\n return filterPrefix(LIST_ORIGINS, familyListOriginMatch[2], () => \"definition origin\", () => true);\n }\n\n const familyListFlagMatch = /^\\/(mcp|skills|personas|members|env|schedule)\\s+(?:--scope(?:=|\\s+)(?:session|workspace)\\s+)?list(?:\\s+.*)?\\s+(--[-\\w]*)$/u.exec(line);\n if (familyListFlagMatch !== null) {\n const descByFlag = new Map(FAMILY_LIST_FLAGS.map((f) => [f.value, f.description]));\n return filterPrefix(\n FAMILY_LIST_FLAGS.map((f) => f.value),\n familyListFlagMatch[2],\n (v) => descByFlag.get(v) ?? \"list option\",\n () => true,\n );\n }\n\n const familyDiscoverFlagMatch = /^\\/(mcp|skills|personas|members|env|schedule)\\s+(?:--scope(?:=|\\s+)(?:session|workspace)\\s+)?discover(?:\\s+.*)?\\s+(--[-\\w]*)$/u.exec(line);\n if (familyDiscoverFlagMatch !== null) {\n const flags = FAMILY_DISCOVER_FLAGS_BY_FAMILY[familyDiscoverFlagMatch[1]] ?? [];\n const descByFlag = new Map(flags.map((f) => [f.value, f.description]));\n return filterPrefix(\n flags.map((f) => f.value),\n familyDiscoverFlagMatch[2],\n (v) => descByFlag.get(v) ?? \"discover option\",\n () => true,\n );\n }\n\n const scheduleFlagMatch = /^\\/schedule\\s+(?:add|replace)\\s+\\S+(?:\\s+.*)?\\s+(--[-\\w]*)$/u.exec(line);\n if (scheduleFlagMatch !== null) {\n const descByFlag = new Map(SCHEDULE_ADD_FLAGS.map((f) => [f.value, f.description]));\n return filterPrefix(\n SCHEDULE_ADD_FLAGS.map((f) => f.value),\n scheduleFlagMatch[1],\n (v) => descByFlag.get(v) ?? \"schedule option\",\n (v) => v !== \"--manual\" && v !== \"--once\" && v !== \"--catchup\" && v !== \"--no-catchup\",\n );\n }\n\n const gateMatch = /^\\/(approve|accept|reject|cancel|edit|answer)\\s+@?([0-9a-f]*)$/iu.exec(line);\n if (gateMatch !== null) {\n const verb = gateMatch[1].toLowerCase();\n const typed = gateMatch[2].toLowerCase();\n const tokenPrefix = line.slice(line.lastIndexOf(\" \") + 1);\n const ids = (snapshot.pendingGateIds ?? [])\n .filter((id) => id.toLowerCase().startsWith(typed))\n .map((id) => `@${id}`);\n return {\n suggestions: ids.map((value) => ({\n value,\n description: \"pending gate\",\n trailingSpace: verb === \"edit\" || verb === \"answer\",\n })),\n prefix: tokenPrefix,\n };\n }\n\n const loopMatch = /^\\/loop\\s+(\\d*)$/u.exec(line);\n if (loopMatch !== null) {\n return filterPrefix(snapshot.loopSequences ?? [], loopMatch[1], () => \"loop\");\n }\n\n const sessionMatch = /^\\/session\\s+(\\S*)$/u.exec(line);\n if (sessionMatch !== null) {\n return filterPrefix(snapshot.sessionNames ?? [], sessionMatch[1], () => \"session\");\n }\n\n const workspaceMatch = /^\\/workspace\\s+(\\S*)$/u.exec(line);\n if (workspaceMatch !== null) {\n return filterPrefix(snapshot.workspaceNames ?? [], workspaceMatch[1], () => \"workspace\");\n }\n\n const modelsFlagMatch = /^\\/models(?:\\s+.*)?\\s+(--[-\\w]*)$/u.exec(line);\n if (modelsFlagMatch !== null) {\n const descByFlag = new Map(MODELS_LIST_FLAGS.map((f) => [f.value, f.description]));\n return filterPrefix(\n MODELS_LIST_FLAGS.map((f) => f.value),\n modelsFlagMatch[1],\n (v) => descByFlag.get(v) ?? \"models option\",\n (v) => v !== \"--all\",\n );\n }\n\n const modelMatch = /^\\/(model|models|child)\\s+(\\S*)$/u.exec(line);\n if (modelMatch !== null) {\n const verb = modelMatch[1];\n const models = snapshot.models ?? [];\n const candidates = verb === \"child\" ? [\"inherit\", ...models.filter((m) => m !== \"inherit\")] : models;\n return filterPrefix(\n candidates,\n modelMatch[2],\n (v) => (v === \"inherit\" ? \"inherit parent route\" : \"model\"),\n () => verb === \"model\",\n );\n }\n\n const modelEffortMatch = /^\\/model\\s+(\\S+)\\s+(\\S*)$/u.exec(line);\n if (modelEffortMatch !== null) {\n const selector = modelEffortMatch[1];\n const efforts = snapshot.effortsForModel?.(selector) ?? snapshot.efforts ?? [];\n return filterPrefix(efforts, modelEffortMatch[2], () => \"reasoning effort\");\n }\n\n const effortMatch = /^\\/effort\\s+(\\S*)$/u.exec(line);\n if (effortMatch !== null) {\n return filterPrefix(snapshot.efforts ?? [], effortMatch[1], () => \"reasoning effort\");\n }\n\n const personaMatch = /^\\/persona\\s+(\\S*)$/u.exec(line);\n if (personaMatch !== null) {\n const personas = snapshot.personas ?? [\"none\"];\n return filterPrefix(\n personas,\n personaMatch[1],\n (v) => (v === \"none\" ? \"clear persona role\" : \"persona\"),\n );\n }\n\n const modeMatch = /^\\/mode\\s+(\\S*)$/u.exec(line);\n if (modeMatch !== null) {\n return filterPrefix(PROPOSAL_POLICIES, modeMatch[1], () => \"proposal review mode\");\n }\n\n const dslMatch = /^((?:await\\s+)?plurnk\\.)([A-Za-z]*)$/u.exec(line);\n if (dslMatch !== null) {\n const opPrefix = dslMatch[1];\n const typed = dslMatch[2];\n return filterPrefix(\n PLURNK_OPS.map((op) => `${opPrefix}${op.toLowerCase()}`),\n `${opPrefix}${typed}`,\n () => \"MCP expression\",\n );\n }\n\n const skillMatch = /(?:^|[\\s([{,])\\$(\\S*)$/u.exec(line);\n if (skillMatch !== null) {\n const skills = snapshot.skills ?? [];\n const descByName = new Map(skills.map((s) => [s.name, s.description ?? \"skill\"]));\n const tokenPrefix = `$${skillMatch[1]}`;\n const hits = skills\n .filter((s) => s.name.toLowerCase().startsWith(skillMatch[1].toLowerCase()))\n .map((s) => ({\n value: `$${s.name}`,\n description: descByName.get(s.name) ?? \"skill\",\n trailingSpace: true,\n }));\n return { suggestions: hits, prefix: tokenPrefix };\n }\n\n return { suggestions: [], prefix: line };\n};\n\n/**\n * {§client-interactive-commands} Computes the longest shared prefix across completion candidates\n * on Unicode code-point boundaries without splitting surrogate pairs.\n */\nexport const longestCommonPrefix = (values: readonly string[]): string => {\n if (values.length === 0) return \"\";\n let shared = Array.from(values[0] ?? \"\");\n for (let i = 1; i < values.length && shared.length > 0; i += 1) {\n const chars = Array.from(values[i] ?? \"\");\n const maxLen = Math.min(shared.length, chars.length);\n let matchLen = 0;\n while (matchLen < maxLen && shared[matchLen] === chars[matchLen]) {\n matchLen += 1;\n }\n shared = shared.slice(0, matchLen);\n }\n return shared.join(\"\");\n};\n\nexport type ComposerInputClassification =\n | { readonly kind: \"empty\" }\n | { readonly kind: \"help\" }\n | { readonly kind: \"review\"; readonly text: string }\n | { readonly kind: \"continue\"; readonly text: string }\n | { readonly kind: \"statement\"; readonly text: string }\n | { readonly kind: \"statement-empty\" }\n | { readonly kind: \"shell\"; readonly command: string }\n | { readonly kind: \"shell-empty\" }\n | { readonly kind: \"slash\"; readonly name: string; readonly argsText: string }\n | { readonly kind: \"prompt\"; readonly text: string };\n\n/**\n * {§client-composer-sigils} Classifies raw interactive composer input into canonical sigil and command forms\n * (`?`, `? <text>`, `... [text]`, `: <stmt>`, `! <cmd>`, `[await ]plurnk.<op>(`, `/<cmd>`, or `prompt`).\n */\nexport const classifyComposerInput = (raw: string): ComposerInputClassification => {\n const trimmed = raw.trim();\n if (trimmed.length === 0) return { kind: \"empty\" };\n if (trimmed === \"?\") return { kind: \"help\" };\n if (/^\\?\\s+/u.test(trimmed)) {\n return { kind: \"review\", text: trimmed.slice(1).trim() };\n }\n if (trimmed === \"...\" || /^\\.\\.\\.\\s+/u.test(trimmed)) {\n return { kind: \"continue\", text: trimmed.slice(3).trim() };\n }\n if (trimmed.startsWith(\":\")) {\n const body = trimmed.slice(1).trim();\n return body.length === 0 ? { kind: \"statement-empty\" } : { kind: \"statement\", text: body };\n }\n if (trimmed.startsWith(\"!\")) {\n const command = trimmed.slice(1).trim();\n return command.length === 0 ? { kind: \"shell-empty\" } : { kind: \"shell\", command };\n }\n if (/^(?:await\\s+)?plurnk\\.[a-z][a-z0-9_]*\\s*\\(/iu.test(trimmed)) {\n return { kind: \"statement\", text: trimmed };\n }\n const slashMatch = /^\\/([a-zA-Z0-9_:-]+)(?:\\s+([\\s\\S]*))?$/u.exec(trimmed);\n if (slashMatch !== null) {\n return {\n kind: \"slash\",\n name: slashMatch[1] ?? \"\",\n argsText: (slashMatch[2] ?? \"\").trim(),\n };\n }\n return { kind: \"prompt\", text: raw };\n};\n\nexport type PromptContentBlock =\n | { readonly type: \"text\"; readonly text: string }\n | { readonly type: \"skill\"; readonly name: string };\n\n/**\n * {§client-composer-sigils} Splits composer text on enabled inline `$<skill>` tokens into interleaved\n * ACPv2 `{ type: \"text\", text }` and `{ type: \"skill\", name }` prompt blocks, leaving unknown `$tokens` as text.\n */\nexport const buildPromptBlocks = (\n text: string,\n availableSkills?: ReadonlySet<string>,\n): readonly PromptContentBlock[] => {\n if (text.length === 0) return [];\n if (availableSkills === undefined || availableSkills.size === 0) {\n return [{ type: \"text\", text }];\n }\n const pattern = /(^|[\\s([{,])\\$([A-Za-z0-9][A-Za-z0-9_-]{0,62})(?=$|[\\s)\\]}.,;:!?])/gu;\n const blocks: PromptContentBlock[] = [];\n let buffer = \"\";\n let cursor = 0;\n\n for (const match of text.matchAll(pattern)) {\n const matchIndex = match.index ?? 0;\n const prefix = match[1] ?? \"\";\n const skillName = match[2] ?? \"\";\n if (!availableSkills.has(skillName)) {\n continue;\n }\n buffer += text.slice(cursor, matchIndex) + prefix;\n if (buffer.length > 0) {\n blocks.push({ type: \"text\", text: buffer });\n buffer = \"\";\n }\n blocks.push({ type: \"skill\", name: skillName });\n cursor = matchIndex + match[0].length;\n }\n\n buffer += text.slice(cursor);\n if (buffer.length > 0) {\n blocks.push({ type: \"text\", text: buffer });\n }\n return blocks;\n};\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
export interface McpWireToolDefinition {
|
|
2
|
+
readonly name: "mcp";
|
|
3
|
+
readonly description: string;
|
|
4
|
+
readonly parameters: {
|
|
5
|
+
readonly type: "object";
|
|
6
|
+
readonly required: readonly ["server", "tool", "aside", "arguments"];
|
|
7
|
+
readonly properties: {
|
|
8
|
+
readonly server: {
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
};
|
|
11
|
+
readonly tool: {
|
|
12
|
+
readonly type: "string";
|
|
13
|
+
};
|
|
14
|
+
readonly aside: {
|
|
15
|
+
readonly type: "string";
|
|
16
|
+
readonly description: string;
|
|
17
|
+
};
|
|
18
|
+
readonly arguments: {
|
|
19
|
+
readonly type: "object";
|
|
20
|
+
readonly additionalProperties: true;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
readonly additionalProperties: false;
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
export declare const MCP_WIRE_TOOL: McpWireToolDefinition;
|
|
27
|
+
//# sourceMappingURL=McpWireTool.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpWireTool.d.ts","sourceRoot":"","sources":["../../src/McpWireTool.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,qBAAqB;IAClC,QAAQ,CAAC,IAAI,EAAE,KAAK,CAAC;IACrB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAC7B,QAAQ,CAAC,UAAU,EAAE;QACjB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;QACxB,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC;QACrE,QAAQ,CAAC,UAAU,EAAE;YACjB,QAAQ,CAAC,MAAM,EAAE;gBAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;aAAE,CAAC;YAC7C,QAAQ,CAAC,IAAI,EAAE;gBAAE,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAA;aAAE,CAAC;YAC3C,QAAQ,CAAC,KAAK,EAAE;gBACZ,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;gBACxB,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;aAChC,CAAC;YACF,QAAQ,CAAC,SAAS,EAAE;gBAChB,QAAQ,CAAC,IAAI,EAAE,QAAQ,CAAC;gBACxB,QAAQ,CAAC,oBAAoB,EAAE,IAAI,CAAC;aACvC,CAAC;SACL,CAAC;QACF,QAAQ,CAAC,oBAAoB,EAAE,KAAK,CAAC;KACxC,CAAC;CACL;AASD,eAAO,MAAM,aAAa,EAAE,qBAoB1B,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// {§mcp-expressions} Canonical universal `mcp` wire tool definition declared on emission turns.
|
|
2
|
+
const freezeDeep = (value) => {
|
|
3
|
+
for (const child of Object.values(value)) {
|
|
4
|
+
if (typeof child === "object" && child !== null)
|
|
5
|
+
freezeDeep(child);
|
|
6
|
+
}
|
|
7
|
+
return Object.freeze(value);
|
|
8
|
+
};
|
|
9
|
+
export const MCP_WIRE_TOOL = freezeDeep({
|
|
10
|
+
name: "mcp",
|
|
11
|
+
description: "Call an MCP tool.",
|
|
12
|
+
parameters: {
|
|
13
|
+
type: "object",
|
|
14
|
+
required: ["server", "tool", "aside", "arguments"],
|
|
15
|
+
properties: {
|
|
16
|
+
server: { type: "string" },
|
|
17
|
+
tool: { type: "string" },
|
|
18
|
+
aside: {
|
|
19
|
+
type: "string",
|
|
20
|
+
description: "Terse intent note.",
|
|
21
|
+
},
|
|
22
|
+
arguments: {
|
|
23
|
+
type: "object",
|
|
24
|
+
additionalProperties: true,
|
|
25
|
+
},
|
|
26
|
+
},
|
|
27
|
+
additionalProperties: false,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
//# sourceMappingURL=McpWireTool.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"McpWireTool.js","sourceRoot":"","sources":["../../src/McpWireTool.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAwBhG,MAAM,UAAU,GAAG,CAAmB,KAAQ,EAAK,EAAE;IACjD,KAAK,MAAM,KAAK,IAAI,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACvC,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,KAAK,IAAI;YAAE,UAAU,CAAC,KAAK,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;AAChC,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAA0B,UAAU,CAAC;IAC3D,IAAI,EAAE,KAAK;IACX,WAAW,EAAE,mBAAmB;IAChC,UAAU,EAAE;QACR,IAAI,EAAE,QAAQ;QACd,QAAQ,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,WAAW,CAAC;QAClD,UAAU,EAAE;YACR,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YAC1B,IAAI,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;YACxB,KAAK,EAAE;gBACH,IAAI,EAAE,QAAQ;gBACd,WAAW,EAAE,oBAAoB;aACpC;YACD,SAAS,EAAE;gBACP,IAAI,EAAE,QAAQ;gBACd,oBAAoB,EAAE,IAAI;aAC7B;SACJ;QACD,oBAAoB,EAAE,KAAK;KAC9B;CACJ,CAAC,CAAC","sourcesContent":["// {§mcp-expressions} Canonical universal `mcp` wire tool definition declared on emission turns.\n\nexport interface McpWireToolDefinition {\n readonly name: \"mcp\";\n readonly description: string;\n readonly parameters: {\n readonly type: \"object\";\n readonly required: readonly [\"server\", \"tool\", \"aside\", \"arguments\"];\n readonly properties: {\n readonly server: { readonly type: \"string\" };\n readonly tool: { readonly type: \"string\" };\n readonly aside: {\n readonly type: \"string\";\n readonly description: string;\n };\n readonly arguments: {\n readonly type: \"object\";\n readonly additionalProperties: true;\n };\n };\n readonly additionalProperties: false;\n };\n}\n\nconst freezeDeep = <T extends object>(value: T): T => {\n for (const child of Object.values(value)) {\n if (typeof child === \"object\" && child !== null) freezeDeep(child);\n }\n return Object.freeze(value);\n};\n\nexport const MCP_WIRE_TOOL: McpWireToolDefinition = freezeDeep({\n name: \"mcp\",\n description: \"Call an MCP tool.\",\n parameters: {\n type: \"object\",\n required: [\"server\", \"tool\", \"aside\", \"arguments\"],\n properties: {\n server: { type: \"string\" },\n tool: { type: \"string\" },\n aside: {\n type: \"string\",\n description: \"Terse intent note.\",\n },\n arguments: {\n type: \"object\",\n additionalProperties: true,\n },\n },\n additionalProperties: false,\n },\n});\n"]}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface ProtectedResourceMetadata {
|
|
2
|
+
readonly resource: string;
|
|
3
|
+
readonly authorizationServers: readonly string[];
|
|
4
|
+
readonly scopesSupported?: readonly string[];
|
|
5
|
+
readonly clientId?: string;
|
|
6
|
+
readonly redirectUri?: string;
|
|
7
|
+
}
|
|
8
|
+
export interface AuthorizationServerMetadata {
|
|
9
|
+
readonly issuer: string;
|
|
10
|
+
readonly authorizationEndpoint: string;
|
|
11
|
+
readonly tokenEndpoint: string;
|
|
12
|
+
readonly registrationEndpoint?: string;
|
|
13
|
+
readonly codeChallengeMethodsSupported?: readonly string[];
|
|
14
|
+
}
|
|
15
|
+
export interface PkcePair {
|
|
16
|
+
readonly codeVerifier: string;
|
|
17
|
+
readonly codeChallenge: string;
|
|
18
|
+
readonly codeChallengeMethod: "S256";
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* {§client-oauth-pkce} Permits `https:` origins and loopback `http:` origins (`127.0.0.1`, `localhost`, `::1`).
|
|
22
|
+
*/
|
|
23
|
+
export declare const isAllowedOAuthUrl: (rawUrl: string) => boolean;
|
|
24
|
+
/**
|
|
25
|
+
* {§client-oauth-pkce} Extracts `resource_metadata="..."` from an RFC 9728 `WWW-Authenticate: Bearer` header.
|
|
26
|
+
*/
|
|
27
|
+
export declare const parseWwwAuthenticateResourceMetadata: (header: string | null | undefined) => string | null;
|
|
28
|
+
/**
|
|
29
|
+
* {§client-oauth-pkce} Builds RFC 8414 §3 path-aware OAuth 2.0 Authorization Server Metadata and
|
|
30
|
+
* OpenID Connect Discovery candidate URLs in priority order.
|
|
31
|
+
*/
|
|
32
|
+
export declare const buildAuthorizationServerMetadataUrls: (issuerUrl: string) => readonly string[];
|
|
33
|
+
/**
|
|
34
|
+
* {§client-oauth-pkce} Fetches and validates RFC 9728 Protected Resource Metadata.
|
|
35
|
+
*/
|
|
36
|
+
export declare const discoverProtectedResourceMetadata: (originOrMetadataUrl: string, fetchImpl?: typeof globalThis.fetch) => Promise<ProtectedResourceMetadata>;
|
|
37
|
+
/**
|
|
38
|
+
* {§client-oauth-pkce} Discovers and issuer-validates RFC 8414 / OIDC Authorization Server Metadata.
|
|
39
|
+
*/
|
|
40
|
+
export declare const discoverAuthorizationServerMetadata: (issuerUrl: string, fetchImpl?: typeof globalThis.fetch) => Promise<AuthorizationServerMetadata>;
|
|
41
|
+
/**
|
|
42
|
+
* {§client-oauth-pkce} Generates an RFC 7636 S256 PKCE verifier and challenge using Web Crypto.
|
|
43
|
+
*/
|
|
44
|
+
export declare const generatePkcePair: () => Promise<PkcePair>;
|
|
45
|
+
/**
|
|
46
|
+
* {§client-oauth-pkce} Extracts the exact `exp` epoch-millisecond timestamp from a JWT access token,
|
|
47
|
+
* or returns `null` for opaque tokens without fabricating a fallback TTL.
|
|
48
|
+
*/
|
|
49
|
+
export declare const parseJwtExpiresAt: (accessToken: string) => number | null;
|
|
50
|
+
/**
|
|
51
|
+
* {§client-oauth-pkce} Resolves token `expiresAt` in epoch ms from `expires_in` seconds (preserving
|
|
52
|
+
* short-lived tokens `<= 10s` faithfully) or JWT `exp`, returning `undefined` when neither is present.
|
|
53
|
+
*/
|
|
54
|
+
export declare const resolveTokenExpiresAt: (expiresInSeconds: unknown, accessToken: string, nowMs?: number) => number | undefined;
|
|
55
|
+
/**
|
|
56
|
+
* {§client-oauth-pkce} Per-key single-flight coordinator so concurrent 401 retries share one
|
|
57
|
+
* OAuth refresh-token exchange instead of racing and invalidating rotated grants.
|
|
58
|
+
*/
|
|
59
|
+
export declare class SingleFlightRefresh<T> {
|
|
60
|
+
#private;
|
|
61
|
+
run(key: string, operation: () => Promise<T>): Promise<T>;
|
|
62
|
+
has(key: string): boolean;
|
|
63
|
+
}
|
|
64
|
+
//# sourceMappingURL=OAuthClient.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuthClient.d.ts","sourceRoot":"","sources":["../../src/OAuthClient.ts"],"names":[],"mappings":"AAKA,MAAM,WAAW,yBAAyB;IACtC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,oBAAoB,EAAE,SAAS,MAAM,EAAE,CAAC;IACjD,QAAQ,CAAC,eAAe,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;IAC7C,QAAQ,CAAC,QAAQ,CAAC,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,CAAC;CACjC;AAED,MAAM,WAAW,2BAA2B;IACxC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,qBAAqB,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,oBAAoB,CAAC,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,6BAA6B,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC9D;AAED,MAAM,WAAW,QAAQ;IACrB,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,QAAQ,CAAC,aAAa,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;CACxC;AAqBD;;GAEG;AACH,eAAO,MAAM,iBAAiB,WAAY,MAAM,KAAG,OASlD,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,oCAAoC,WAAY,MAAM,GAAG,IAAI,GAAG,SAAS,KAAG,MAAM,GAAG,IAKjG,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,oCAAoC,cAAe,MAAM,KAAG,SAAS,MAAM,EAevF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,iCAAiC,wBACrB,MAAM,cAChB,OAAO,UAAU,CAAC,KAAK,KACnC,OAAO,CAAC,yBAAyB,CAgCnC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,mCAAmC,cACjC,MAAM,cACN,OAAO,UAAU,CAAC,KAAK,KACnC,OAAO,CAAC,2BAA2B,CAoDrC,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,gBAAgB,QAAa,OAAO,CAAC,QAAQ,CAazD,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,iBAAiB,gBAAiB,MAAM,KAAG,MAAM,GAAG,IAchE,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,qBAAqB,qBACZ,OAAO,eACZ,MAAM,qBAEpB,MAAM,GAAG,SAMX,CAAC;AAEF;;;GAGG;AACH,qBAAa,mBAAmB,CAAC,CAAC;;IAG9B,GAAG,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,CAUxD;IAED,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAExB;CACJ"}
|
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
// {§client-oauth-pkce} Browser/Node-neutral OAuth 2.1 / OIDC discovery, Web Crypto PKCE S256,
|
|
2
|
+
// JWT expiry inspection, and per-origin single-flight token refresh deduplication.
|
|
3
|
+
import { isRecord } from "./guards.js";
|
|
4
|
+
import { isLoopbackHost } from "./HttpOrigin.js";
|
|
5
|
+
const toBase64Url = (bytes) => {
|
|
6
|
+
let binary = "";
|
|
7
|
+
for (const byte of bytes)
|
|
8
|
+
binary += String.fromCharCode(byte);
|
|
9
|
+
return btoa(binary).replace(/\+/gu, "-").replace(/\//gu, "_").replace(/=+$/gu, "");
|
|
10
|
+
};
|
|
11
|
+
const fromBase64UrlToUtf8 = (segment) => {
|
|
12
|
+
try {
|
|
13
|
+
const normalized = segment.replace(/-/gu, "+").replace(/_/gu, "/");
|
|
14
|
+
const padded = normalized + "=".repeat((4 - (normalized.length % 4)) % 4);
|
|
15
|
+
const binary = atob(padded);
|
|
16
|
+
const bytes = new Uint8Array(binary.length);
|
|
17
|
+
for (let i = 0; i < binary.length; i += 1)
|
|
18
|
+
bytes[i] = binary.charCodeAt(i);
|
|
19
|
+
return new TextDecoder("utf-8", { fatal: true }).decode(bytes);
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* {§client-oauth-pkce} Permits `https:` origins and loopback `http:` origins (`127.0.0.1`, `localhost`, `::1`).
|
|
27
|
+
*/
|
|
28
|
+
export const isAllowedOAuthUrl = (rawUrl) => {
|
|
29
|
+
try {
|
|
30
|
+
const parsed = new URL(rawUrl);
|
|
31
|
+
if (parsed.username.length > 0 || parsed.password.length > 0)
|
|
32
|
+
return false;
|
|
33
|
+
if (parsed.protocol === "https:")
|
|
34
|
+
return true;
|
|
35
|
+
return parsed.protocol === "http:" && isLoopbackHost(parsed.hostname);
|
|
36
|
+
}
|
|
37
|
+
catch {
|
|
38
|
+
return false;
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
/**
|
|
42
|
+
* {§client-oauth-pkce} Extracts `resource_metadata="..."` from an RFC 9728 `WWW-Authenticate: Bearer` header.
|
|
43
|
+
*/
|
|
44
|
+
export const parseWwwAuthenticateResourceMetadata = (header) => {
|
|
45
|
+
if (typeof header !== "string" || header.length === 0)
|
|
46
|
+
return null;
|
|
47
|
+
const match = /\bresource_metadata="([^"]+)"/iu.exec(header);
|
|
48
|
+
const candidate = match?.[1]?.trim() ?? "";
|
|
49
|
+
return candidate.length > 0 && isAllowedOAuthUrl(candidate) ? candidate : null;
|
|
50
|
+
};
|
|
51
|
+
/**
|
|
52
|
+
* {§client-oauth-pkce} Builds RFC 8414 §3 path-aware OAuth 2.0 Authorization Server Metadata and
|
|
53
|
+
* OpenID Connect Discovery candidate URLs in priority order.
|
|
54
|
+
*/
|
|
55
|
+
export const buildAuthorizationServerMetadataUrls = (issuerUrl) => {
|
|
56
|
+
const parsed = new URL(issuerUrl);
|
|
57
|
+
if (!isAllowedOAuthUrl(parsed.href)) {
|
|
58
|
+
throw new Error(`Authorization server issuer '${issuerUrl}' must use https:// or loopback http://.`);
|
|
59
|
+
}
|
|
60
|
+
const cleanPath = parsed.pathname.replace(/\/+$/u, "");
|
|
61
|
+
const oauthUrl = cleanPath.length === 0
|
|
62
|
+
? `${parsed.origin}/.well-known/oauth-authorization-server`
|
|
63
|
+
: `${parsed.origin}/.well-known/oauth-authorization-server${cleanPath}`;
|
|
64
|
+
const oidcUrl = cleanPath.length === 0
|
|
65
|
+
? `${parsed.origin}/.well-known/openid-configuration`
|
|
66
|
+
: `${parsed.origin}${cleanPath}/.well-known/openid-configuration`;
|
|
67
|
+
return oauthUrl === oidcUrl ? [oauthUrl] : [oauthUrl, oidcUrl];
|
|
68
|
+
};
|
|
69
|
+
/**
|
|
70
|
+
* {§client-oauth-pkce} Fetches and validates RFC 9728 Protected Resource Metadata.
|
|
71
|
+
*/
|
|
72
|
+
export const discoverProtectedResourceMetadata = async (originOrMetadataUrl, fetchImpl = globalThis.fetch) => {
|
|
73
|
+
const parsed = new URL(originOrMetadataUrl);
|
|
74
|
+
const metadataUrl = parsed.pathname.includes("/.well-known/")
|
|
75
|
+
? parsed.href
|
|
76
|
+
: `${parsed.origin}/.well-known/oauth-protected-resource`;
|
|
77
|
+
if (!isAllowedOAuthUrl(metadataUrl)) {
|
|
78
|
+
throw new Error(`Protected resource metadata URL '${metadataUrl}' must use https:// or loopback http://.`);
|
|
79
|
+
}
|
|
80
|
+
const res = await fetchImpl(metadataUrl, { headers: { accept: "application/json" } });
|
|
81
|
+
if (!res.ok) {
|
|
82
|
+
throw new Error(`Protected resource metadata discovery failed with HTTP ${res.status}.`);
|
|
83
|
+
}
|
|
84
|
+
const body = await res.json();
|
|
85
|
+
if (!isRecord(body) || typeof body.resource !== "string" || !Array.isArray(body.authorization_servers)) {
|
|
86
|
+
throw new Error("Protected resource metadata is missing required 'resource' or 'authorization_servers'.");
|
|
87
|
+
}
|
|
88
|
+
const servers = body.authorization_servers.filter((s) => typeof s === "string" && isAllowedOAuthUrl(s));
|
|
89
|
+
if (servers.length === 0) {
|
|
90
|
+
throw new Error("Protected resource metadata advertised no valid authorization_servers.");
|
|
91
|
+
}
|
|
92
|
+
const scopes = Array.isArray(body.scopes_supported)
|
|
93
|
+
? body.scopes_supported.filter((s) => typeof s === "string" && s.length > 0)
|
|
94
|
+
: undefined;
|
|
95
|
+
return {
|
|
96
|
+
resource: body.resource,
|
|
97
|
+
authorizationServers: servers,
|
|
98
|
+
...(scopes === undefined ? {} : { scopesSupported: scopes }),
|
|
99
|
+
...(typeof body.client_id === "string" && body.client_id.length > 0 ? { clientId: body.client_id } : {}),
|
|
100
|
+
...(typeof body.redirect_uri === "string" && body.redirect_uri.length > 0 ? { redirectUri: body.redirect_uri } : {}),
|
|
101
|
+
};
|
|
102
|
+
};
|
|
103
|
+
/**
|
|
104
|
+
* {§client-oauth-pkce} Discovers and issuer-validates RFC 8414 / OIDC Authorization Server Metadata.
|
|
105
|
+
*/
|
|
106
|
+
export const discoverAuthorizationServerMetadata = async (issuerUrl, fetchImpl = globalThis.fetch) => {
|
|
107
|
+
const urls = buildAuthorizationServerMetadataUrls(issuerUrl);
|
|
108
|
+
const expectedIssuer = issuerUrl.replace(/\/+$/u, "");
|
|
109
|
+
let lastError = null;
|
|
110
|
+
for (const url of urls) {
|
|
111
|
+
try {
|
|
112
|
+
const res = await fetchImpl(url, { headers: { accept: "application/json" } });
|
|
113
|
+
if (!res.ok) {
|
|
114
|
+
lastError = new Error(`Metadata endpoint '${url}' returned HTTP ${res.status}.`);
|
|
115
|
+
continue;
|
|
116
|
+
}
|
|
117
|
+
const body = await res.json();
|
|
118
|
+
if (!isRecord(body)
|
|
119
|
+
|| typeof body.issuer !== "string"
|
|
120
|
+
|| typeof body.authorization_endpoint !== "string"
|
|
121
|
+
|| typeof body.token_endpoint !== "string") {
|
|
122
|
+
lastError = new Error(`Metadata at '${url}' is missing issuer, authorization_endpoint, or token_endpoint.`);
|
|
123
|
+
continue;
|
|
124
|
+
}
|
|
125
|
+
if (body.issuer.replace(/\/+$/u, "") !== expectedIssuer) {
|
|
126
|
+
throw new Error(`Authorization server issuer mismatch: expected '${issuerUrl}', got '${body.issuer}'.`);
|
|
127
|
+
}
|
|
128
|
+
if (!isAllowedOAuthUrl(body.authorization_endpoint) || !isAllowedOAuthUrl(body.token_endpoint)) {
|
|
129
|
+
throw new Error("Authorization and token endpoints must use https:// or loopback http://.");
|
|
130
|
+
}
|
|
131
|
+
const methods = Array.isArray(body.code_challenge_methods_supported)
|
|
132
|
+
? body.code_challenge_methods_supported.filter((m) => typeof m === "string")
|
|
133
|
+
: undefined;
|
|
134
|
+
if (methods !== undefined && methods.length > 0 && !methods.includes("S256")) {
|
|
135
|
+
throw new Error("Authorization server does not support PKCE S256.");
|
|
136
|
+
}
|
|
137
|
+
return {
|
|
138
|
+
issuer: body.issuer,
|
|
139
|
+
authorizationEndpoint: body.authorization_endpoint,
|
|
140
|
+
tokenEndpoint: body.token_endpoint,
|
|
141
|
+
...(typeof body.registration_endpoint === "string" && isAllowedOAuthUrl(body.registration_endpoint)
|
|
142
|
+
? { registrationEndpoint: body.registration_endpoint }
|
|
143
|
+
: {}),
|
|
144
|
+
...(methods === undefined ? {} : { codeChallengeMethodsSupported: methods }),
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
catch (cause) {
|
|
148
|
+
const err = cause instanceof Error ? cause : new Error(String(cause));
|
|
149
|
+
if (err.message.includes("issuer mismatch") || err.message.includes("PKCE S256") || err.message.includes("endpoints must use")) {
|
|
150
|
+
throw err;
|
|
151
|
+
}
|
|
152
|
+
lastError = err;
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
throw lastError ?? new Error(`Failed to discover authorization server metadata for '${issuerUrl}'.`);
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* {§client-oauth-pkce} Generates an RFC 7636 S256 PKCE verifier and challenge using Web Crypto.
|
|
159
|
+
*/
|
|
160
|
+
export const generatePkcePair = async () => {
|
|
161
|
+
const random = new Uint8Array(32);
|
|
162
|
+
globalThis.crypto.getRandomValues(random);
|
|
163
|
+
const codeVerifier = toBase64Url(random);
|
|
164
|
+
const digest = await globalThis.crypto.subtle.digest("SHA-256", new TextEncoder().encode(codeVerifier));
|
|
165
|
+
return {
|
|
166
|
+
codeVerifier,
|
|
167
|
+
codeChallenge: toBase64Url(new Uint8Array(digest)),
|
|
168
|
+
codeChallengeMethod: "S256",
|
|
169
|
+
};
|
|
170
|
+
};
|
|
171
|
+
/**
|
|
172
|
+
* {§client-oauth-pkce} Extracts the exact `exp` epoch-millisecond timestamp from a JWT access token,
|
|
173
|
+
* or returns `null` for opaque tokens without fabricating a fallback TTL.
|
|
174
|
+
*/
|
|
175
|
+
export const parseJwtExpiresAt = (accessToken) => {
|
|
176
|
+
const parts = accessToken.split(".");
|
|
177
|
+
if (parts.length !== 3 || parts[1].length === 0)
|
|
178
|
+
return null;
|
|
179
|
+
const json = fromBase64UrlToUtf8(parts[1]);
|
|
180
|
+
if (json === null)
|
|
181
|
+
return null;
|
|
182
|
+
try {
|
|
183
|
+
const payload = JSON.parse(json);
|
|
184
|
+
if (!isRecord(payload) || typeof payload.exp !== "number" || !Number.isFinite(payload.exp) || payload.exp <= 0) {
|
|
185
|
+
return null;
|
|
186
|
+
}
|
|
187
|
+
return Math.floor(payload.exp * 1000);
|
|
188
|
+
}
|
|
189
|
+
catch {
|
|
190
|
+
return null;
|
|
191
|
+
}
|
|
192
|
+
};
|
|
193
|
+
/**
|
|
194
|
+
* {§client-oauth-pkce} Resolves token `expiresAt` in epoch ms from `expires_in` seconds (preserving
|
|
195
|
+
* short-lived tokens `<= 10s` faithfully) or JWT `exp`, returning `undefined` when neither is present.
|
|
196
|
+
*/
|
|
197
|
+
export const resolveTokenExpiresAt = (expiresInSeconds, accessToken, nowMs = Date.now()) => {
|
|
198
|
+
if (typeof expiresInSeconds === "number" && Number.isFinite(expiresInSeconds) && expiresInSeconds > 0) {
|
|
199
|
+
return nowMs + Math.floor(expiresInSeconds * 1000);
|
|
200
|
+
}
|
|
201
|
+
const jwtExp = parseJwtExpiresAt(accessToken);
|
|
202
|
+
return jwtExp !== null ? jwtExp : undefined;
|
|
203
|
+
};
|
|
204
|
+
/**
|
|
205
|
+
* {§client-oauth-pkce} Per-key single-flight coordinator so concurrent 401 retries share one
|
|
206
|
+
* OAuth refresh-token exchange instead of racing and invalidating rotated grants.
|
|
207
|
+
*/
|
|
208
|
+
export class SingleFlightRefresh {
|
|
209
|
+
#inFlight = new Map();
|
|
210
|
+
run(key, operation) {
|
|
211
|
+
const existing = this.#inFlight.get(key);
|
|
212
|
+
if (existing !== undefined)
|
|
213
|
+
return existing;
|
|
214
|
+
const promise = operation().finally(() => {
|
|
215
|
+
if (this.#inFlight.get(key) === promise) {
|
|
216
|
+
this.#inFlight.delete(key);
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
this.#inFlight.set(key, promise);
|
|
220
|
+
return promise;
|
|
221
|
+
}
|
|
222
|
+
has(key) {
|
|
223
|
+
return this.#inFlight.has(key);
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
//# sourceMappingURL=OAuthClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OAuthClient.js","sourceRoot":"","sources":["../../src/OAuthClient.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,mFAAmF;AACnF,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAwBjD,MAAM,WAAW,GA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AAC,CAAC;IAC9C,OAAO,MAAM,KAAK,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;AAChD,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,OAAO,mBAAmB;IACnB,SAAS,GAAG,IAAI,GAAG,EAAsB,CAAC;IAEnD,GAAG,CAAC,GAAW,EAAE,SAA2B;QACxC,MAAM,QAAQ,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACzC,IAAI,QAAQ,KAAK,SAAS;YAAE,OAAO,QAAQ,CAAC;QAC5C,MAAM,OAAO,GAAG,SAAS,EAAE,CAAC,OAAO,CAAC,GAAG,EAAE;YACrC,IAAI,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,KAAK,OAAO,EAAE,CAAC;gBACtC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;YAC/B,CAAC;QACL,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;QACjC,OAAO,OAAO,CAAC;IACnB,CAAC;IAED,GAAG,CAAC,GAAW;QACX,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;IACnC,CAAC;CACJ","sourcesContent":["// {§client-oauth-pkce} Browser/Node-neutral OAuth 2.1 / OIDC discovery, Web Crypto PKCE S256,\n// JWT expiry inspection, and per-origin single-flight token refresh deduplication.\nimport { isRecord } from \"./guards.ts\";\nimport { isLoopbackHost } from \"./HttpOrigin.ts\";\n\nexport interface ProtectedResourceMetadata {\n readonly resource: string;\n readonly authorizationServers: readonly string[];\n readonly scopesSupported?: readonly string[];\n readonly clientId?: string;\n readonly redirectUri?: string;\n}\n\nexport interface AuthorizationServerMetadata {\n readonly issuer: string;\n readonly authorizationEndpoint: string;\n readonly tokenEndpoint: string;\n readonly registrationEndpoint?: string;\n readonly codeChallengeMethodsSupported?: readonly string[];\n}\n\nexport interface PkcePair {\n readonly codeVerifier: string;\n readonly codeChallenge: string;\n readonly codeChallengeMethod: \"S256\";\n}\n\nconst toBase64Url = (bytes: Uint8Array): string => {\n let binary = \"\";\n for (const byte of bytes) binary += String.fromCharCode(byte);\n return btoa(binary).replace(/\\+/gu, \"-\").replace(/\\//gu, \"_\").replace(/=+$/gu, \"\");\n};\n\nconst fromBase64UrlToUtf8 = (segment: string): string | null => {\n try {\n const normalized = segment.replace(/-/gu, \"+\").replace(/_/gu, \"/\");\n const padded = normalized + \"=\".repeat((4 - (normalized.length % 4)) % 4);\n const binary = atob(padded);\n const bytes = new Uint8Array(binary.length);\n for (let i = 0; i < binary.length; i += 1) bytes[i] = binary.charCodeAt(i);\n return new TextDecoder(\"utf-8\", { fatal: true }).decode(bytes);\n } catch {\n return null;\n }\n};\n\n/**\n * {§client-oauth-pkce} Permits `https:` origins and loopback `http:` origins (`127.0.0.1`, `localhost`, `::1`).\n */\nexport const isAllowedOAuthUrl = (rawUrl: string): boolean => {\n try {\n const parsed = new URL(rawUrl);\n if (parsed.username.length > 0 || parsed.password.length > 0) return false;\n if (parsed.protocol === \"https:\") return true;\n return parsed.protocol === \"http:\" && isLoopbackHost(parsed.hostname);\n } catch {\n return false;\n }\n};\n\n/**\n * {§client-oauth-pkce} Extracts `resource_metadata=\"...\"` from an RFC 9728 `WWW-Authenticate: Bearer` header.\n */\nexport const parseWwwAuthenticateResourceMetadata = (header: string | null | undefined): string | null => {\n if (typeof header !== \"string\" || header.length === 0) return null;\n const match = /\\bresource_metadata=\"([^\"]+)\"/iu.exec(header);\n const candidate = match?.[1]?.trim() ?? \"\";\n return candidate.length > 0 && isAllowedOAuthUrl(candidate) ? candidate : null;\n};\n\n/**\n * {§client-oauth-pkce} Builds RFC 8414 §3 path-aware OAuth 2.0 Authorization Server Metadata and\n * OpenID Connect Discovery candidate URLs in priority order.\n */\nexport const buildAuthorizationServerMetadataUrls = (issuerUrl: string): readonly string[] => {\n const parsed = new URL(issuerUrl);\n if (!isAllowedOAuthUrl(parsed.href)) {\n throw new Error(`Authorization server issuer '${issuerUrl}' must use https:// or loopback http://.`);\n }\n const cleanPath = parsed.pathname.replace(/\\/+$/u, \"\");\n const oauthUrl =\n cleanPath.length === 0\n ? `${parsed.origin}/.well-known/oauth-authorization-server`\n : `${parsed.origin}/.well-known/oauth-authorization-server${cleanPath}`;\n const oidcUrl =\n cleanPath.length === 0\n ? `${parsed.origin}/.well-known/openid-configuration`\n : `${parsed.origin}${cleanPath}/.well-known/openid-configuration`;\n return oauthUrl === oidcUrl ? [oauthUrl] : [oauthUrl, oidcUrl];\n};\n\n/**\n * {§client-oauth-pkce} Fetches and validates RFC 9728 Protected Resource Metadata.\n */\nexport const discoverProtectedResourceMetadata = async (\n originOrMetadataUrl: string,\n fetchImpl: typeof globalThis.fetch = globalThis.fetch,\n): Promise<ProtectedResourceMetadata> => {\n const parsed = new URL(originOrMetadataUrl);\n const metadataUrl = parsed.pathname.includes(\"/.well-known/\")\n ? parsed.href\n : `${parsed.origin}/.well-known/oauth-protected-resource`;\n if (!isAllowedOAuthUrl(metadataUrl)) {\n throw new Error(`Protected resource metadata URL '${metadataUrl}' must use https:// or loopback http://.`);\n }\n const res = await fetchImpl(metadataUrl, { headers: { accept: \"application/json\" } });\n if (!res.ok) {\n throw new Error(`Protected resource metadata discovery failed with HTTP ${res.status}.`);\n }\n const body: unknown = await res.json();\n if (!isRecord(body) || typeof body.resource !== \"string\" || !Array.isArray(body.authorization_servers)) {\n throw new Error(\"Protected resource metadata is missing required 'resource' or 'authorization_servers'.\");\n }\n const servers = body.authorization_servers.filter(\n (s): s is string => typeof s === \"string\" && isAllowedOAuthUrl(s),\n );\n if (servers.length === 0) {\n throw new Error(\"Protected resource metadata advertised no valid authorization_servers.\");\n }\n const scopes = Array.isArray(body.scopes_supported)\n ? body.scopes_supported.filter((s): s is string => typeof s === \"string\" && s.length > 0)\n : undefined;\n return {\n resource: body.resource,\n authorizationServers: servers,\n ...(scopes === undefined ? {} : { scopesSupported: scopes }),\n ...(typeof body.client_id === \"string\" && body.client_id.length > 0 ? { clientId: body.client_id } : {}),\n ...(typeof body.redirect_uri === \"string\" && body.redirect_uri.length > 0 ? { redirectUri: body.redirect_uri } : {}),\n };\n};\n\n/**\n * {§client-oauth-pkce} Discovers and issuer-validates RFC 8414 / OIDC Authorization Server Metadata.\n */\nexport const discoverAuthorizationServerMetadata = async (\n issuerUrl: string,\n fetchImpl: typeof globalThis.fetch = globalThis.fetch,\n): Promise<AuthorizationServerMetadata> => {\n const urls = buildAuthorizationServerMetadataUrls(issuerUrl);\n const expectedIssuer = issuerUrl.replace(/\\/+$/u, \"\");\n let lastError: Error | null = null;\n\n for (const url of urls) {\n try {\n const res = await fetchImpl(url, { headers: { accept: \"application/json\" } });\n if (!res.ok) {\n lastError = new Error(`Metadata endpoint '${url}' returned HTTP ${res.status}.`);\n continue;\n }\n const body: unknown = await res.json();\n if (\n !isRecord(body)\n || typeof body.issuer !== \"string\"\n || typeof body.authorization_endpoint !== \"string\"\n || typeof body.token_endpoint !== \"string\"\n ) {\n lastError = new Error(`Metadata at '${url}' is missing issuer, authorization_endpoint, or token_endpoint.`);\n continue;\n }\n if (body.issuer.replace(/\\/+$/u, \"\") !== expectedIssuer) {\n throw new Error(`Authorization server issuer mismatch: expected '${issuerUrl}', got '${body.issuer}'.`);\n }\n if (!isAllowedOAuthUrl(body.authorization_endpoint) || !isAllowedOAuthUrl(body.token_endpoint)) {\n throw new Error(\"Authorization and token endpoints must use https:// or loopback http://.\");\n }\n const methods = Array.isArray(body.code_challenge_methods_supported)\n ? body.code_challenge_methods_supported.filter((m): m is string => typeof m === \"string\")\n : undefined;\n if (methods !== undefined && methods.length > 0 && !methods.includes(\"S256\")) {\n throw new Error(\"Authorization server does not support PKCE S256.\");\n }\n return {\n issuer: body.issuer,\n authorizationEndpoint: body.authorization_endpoint,\n tokenEndpoint: body.token_endpoint,\n ...(typeof body.registration_endpoint === \"string\" && isAllowedOAuthUrl(body.registration_endpoint)\n ? { registrationEndpoint: body.registration_endpoint }\n : {}),\n ...(methods === undefined ? {} : { codeChallengeMethodsSupported: methods }),\n };\n } catch (cause) {\n const err = cause instanceof Error ? cause : new Error(String(cause));\n if (err.message.includes(\"issuer mismatch\") || err.message.includes(\"PKCE S256\") || err.message.includes(\"endpoints must use\")) {\n throw err;\n }\n lastError = err;\n }\n }\n throw lastError ?? new Error(`Failed to discover authorization server metadata for '${issuerUrl}'.`);\n};\n\n/**\n * {§client-oauth-pkce} Generates an RFC 7636 S256 PKCE verifier and challenge using Web Crypto.\n */\nexport const generatePkcePair = async (): Promise<PkcePair> => {\n const random = new Uint8Array(32);\n globalThis.crypto.getRandomValues(random);\n const codeVerifier = toBase64Url(random);\n const digest = await globalThis.crypto.subtle.digest(\n \"SHA-256\",\n new TextEncoder().encode(codeVerifier),\n );\n return {\n codeVerifier,\n codeChallenge: toBase64Url(new Uint8Array(digest)),\n codeChallengeMethod: \"S256\",\n };\n};\n\n/**\n * {§client-oauth-pkce} Extracts the exact `exp` epoch-millisecond timestamp from a JWT access token,\n * or returns `null` for opaque tokens without fabricating a fallback TTL.\n */\nexport const parseJwtExpiresAt = (accessToken: string): number | null => {\n const parts = accessToken.split(\".\");\n if (parts.length !== 3 || parts[1].length === 0) return null;\n const json = fromBase64UrlToUtf8(parts[1]);\n if (json === null) return null;\n try {\n const payload: unknown = JSON.parse(json);\n if (!isRecord(payload) || typeof payload.exp !== \"number\" || !Number.isFinite(payload.exp) || payload.exp <= 0) {\n return null;\n }\n return Math.floor(payload.exp * 1000);\n } catch {\n return null;\n }\n};\n\n/**\n * {§client-oauth-pkce} Resolves token `expiresAt` in epoch ms from `expires_in` seconds (preserving\n * short-lived tokens `<= 10s` faithfully) or JWT `exp`, returning `undefined` when neither is present.\n */\nexport const resolveTokenExpiresAt = (\n expiresInSeconds: unknown,\n accessToken: string,\n nowMs = Date.now(),\n): number | undefined => {\n if (typeof expiresInSeconds === \"number\" && Number.isFinite(expiresInSeconds) && expiresInSeconds > 0) {\n return nowMs + Math.floor(expiresInSeconds * 1000);\n }\n const jwtExp = parseJwtExpiresAt(accessToken);\n return jwtExp !== null ? jwtExp : undefined;\n};\n\n/**\n * {§client-oauth-pkce} Per-key single-flight coordinator so concurrent 401 retries share one\n * OAuth refresh-token exchange instead of racing and invalidating rotated grants.\n */\nexport class SingleFlightRefresh<T> {\n readonly #inFlight = new Map<string, Promise<T>>();\n\n run(key: string, operation: () => Promise<T>): Promise<T> {\n const existing = this.#inFlight.get(key);\n if (existing !== undefined) return existing;\n const promise = operation().finally(() => {\n if (this.#inFlight.get(key) === promise) {\n this.#inFlight.delete(key);\n }\n });\n this.#inFlight.set(key, promise);\n return promise;\n }\n\n has(key: string): boolean {\n return this.#inFlight.has(key);\n }\n}\n"]}
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { ProblemDetails } from "./types.generated.ts";
|
|
2
|
+
export type ScheduleStatus = "open" | "done" | "fail";
|
|
3
|
+
export interface ScheduledToolCall {
|
|
4
|
+
readonly server: string;
|
|
5
|
+
readonly tool: string;
|
|
6
|
+
readonly arguments?: Readonly<Record<string, unknown>>;
|
|
7
|
+
readonly aside?: string;
|
|
8
|
+
}
|
|
9
|
+
export interface ScheduledStepReceipt {
|
|
10
|
+
readonly index: number;
|
|
11
|
+
readonly server: string;
|
|
12
|
+
readonly tool: string;
|
|
13
|
+
readonly status: number;
|
|
14
|
+
readonly uri?: string;
|
|
15
|
+
readonly preview?: string;
|
|
16
|
+
readonly problem?: ProblemDetails;
|
|
17
|
+
}
|
|
18
|
+
export interface ScheduleRunResult {
|
|
19
|
+
readonly alias: string;
|
|
20
|
+
readonly status: ScheduleStatus;
|
|
21
|
+
readonly loopId?: number | null;
|
|
22
|
+
readonly lastFiredAt?: string | null;
|
|
23
|
+
readonly doneAt?: string | null;
|
|
24
|
+
readonly results?: readonly ScheduledStepReceipt[];
|
|
25
|
+
}
|
|
26
|
+
export declare const SCHEDULE_USAGE = "usage: /schedule [list|show|inspect|discover|add|replace|run|done|reopen|enable|disable|remove] [options]\n\nsubcommands:\n list [query] [--state <s>] [--origin <o>] [--offset <n>] [--limit <n>]\n List or filter workspace schedules and macros (default).\n show <alias> | inspect <alias> Inspect one schedule or macro definition in full.\n discover [<rule>] [--cursor <c>] [--limit <n>]\n Show workspace clock or preview occurrences of <rule>.\n add <alias> <session> <rule> <prompt...> Add a prompt schedule (cron, RRULE, +duration, ISO, manual, or once).\n add <alias> [--manual|--once|--rule <r>] --target <session> [--persona <p>] [--catchup|--no-catchup] --prompt <text>\n add <alias> [--manual|--once|--rule <r>] --step <server>.<tool> ['<json>'] [--aside <label>] [--step ...]\n add <alias> [--manual|--once|--rule <r>] --run '<json-steps>'\n replace ... Replace an existing schedule or macro using any add form.\n run <alias> Execute a schedule or macro now and display step receipts.\n done <alias> | reopen <alias> Mark an obligation done or reopen it.\n enable <alias> | disable <alias> Enable or disable a schedule.\n remove <alias> Remove a workspace schedule.\n";
|
|
27
|
+
export declare const SCHEDULE_ADD_FLAGS: readonly {
|
|
28
|
+
readonly value: string;
|
|
29
|
+
readonly description: string;
|
|
30
|
+
}[];
|
|
31
|
+
/**
|
|
32
|
+
* {§acp-action-binding} Shell-style tokenizer for interactive slash-command arguments so quoted rules
|
|
33
|
+
* (`"0 9 * * 1-5"`) and JSON step payloads (`'{"text":"echo hi"}'`) stay intact.
|
|
34
|
+
*/
|
|
35
|
+
export declare const tokenizeSlashArgs: (raw: string) => string[];
|
|
36
|
+
export interface ParsedScheduleFamilyCommand {
|
|
37
|
+
readonly scopePrefix: "workspace";
|
|
38
|
+
readonly sub: string;
|
|
39
|
+
readonly rest: readonly string[];
|
|
40
|
+
readonly actionName: string;
|
|
41
|
+
readonly params: Record<string, unknown>;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* {§acp-action-binding} Canonical `schedule` subcommand parser shared by `parseFamilyCommand`, ACP, CLI, and Web.
|
|
45
|
+
*/
|
|
46
|
+
export declare const parseScheduleFamilyArgs: (rawSub: string, rest: readonly string[]) => ParsedScheduleFamilyCommand;
|
|
47
|
+
/** {§acp-action-binding} Formats schedule definition rows for `list`, `add`, `replace`, `enable`, and `disable`. */
|
|
48
|
+
export declare const formatScheduleRows: (result: Readonly<Record<string, unknown>>) => string;
|
|
49
|
+
/** {§acp-action-binding} Formats a full single-alias schedule inspection view (`/schedule show|inspect <alias>`). */
|
|
50
|
+
export declare const formatScheduleInspect: (entry: Readonly<Record<string, unknown>>) => string;
|
|
51
|
+
/** {§acp-action-binding} Formats compact per-step macro receipts (`results[]`) for CLI, ACP, and Web. */
|
|
52
|
+
export declare const formatScheduleStepReceipts: (rawResults: unknown) => string[];
|
|
53
|
+
export declare const formatScheduleRunResult: (fallbackAlias: string, result: Readonly<Record<string, unknown>>) => string;
|
|
54
|
+
export declare const formatScheduleStatusResult: (fallbackAlias: string, result: Readonly<Record<string, unknown>>) => string;
|
|
55
|
+
/**
|
|
56
|
+
* {§client-schedule-command} Extracts a structured `ProblemDetails` from a schedule usage or RPC failure,
|
|
57
|
+
* attaching `recovery: "/schedule reopen <alias>"` on `409 already-done` conflicts when absent.
|
|
58
|
+
*/
|
|
59
|
+
export declare const extractScheduleProblem: (error: unknown, fallbackAlias?: string) => ProblemDetails | null;
|
|
60
|
+
//# sourceMappingURL=ScheduleCommand.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ScheduleCommand.d.ts","sourceRoot":"","sources":["../../src/ScheduleCommand.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAE3D,MAAM,MAAM,cAAc,GAAG,MAAM,GAAG,MAAM,GAAG,MAAM,CAAC;AAEtD,MAAM,WAAW,iBAAiB;IAC9B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,SAA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