@openape/apes 1.28.13 → 1.29.1

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/dist/index.d.ts CHANGED
@@ -1,163 +1,6 @@
1
- import { OpenApeGrantRequest, ScopeRiskLevel, OpenApeCliAuthorizationDetail, OpenApeExecutionContext } from '@openape/core';
2
-
3
- interface ShapesAdapter {
4
- schema: string;
5
- cli: {
6
- id: string;
7
- executable: string;
8
- audience?: string;
9
- version?: string;
10
- };
11
- operations: ShapesOperation[];
12
- }
13
- interface ShapesOperation {
14
- id: string;
15
- command: string[];
16
- /**
17
- * Positional argument names. Entries prefixed with `=` are literal matchers:
18
- * the corresponding argv token must equal the suffix (not bound as a variable).
19
- * Enables interleaved-literal command shapes like
20
- * `iurio project <id> workspace <id> task <id> archive`.
21
- */
22
- positionals?: string[];
23
- required_options?: string[];
24
- display: string;
25
- action: string;
26
- risk: ScopeRiskLevel;
27
- resource_chain: string[];
28
- exact_command?: boolean;
29
- }
30
- interface LoadedAdapter {
31
- adapter: ShapesAdapter;
32
- source: string;
33
- digest: string;
34
- /**
35
- * True when this adapter was synthesized in-memory for a CLI that has no
36
- * registered shape. Synthetic adapters bypass `resolveCommand()` and are
37
- * fed into the grant pipeline via `buildGenericResolved()` directly.
38
- * See `shapes/generic.ts`.
39
- */
40
- synthetic?: boolean;
41
- }
42
- interface ResolvedCommand {
43
- adapter: ShapesAdapter;
44
- source: string;
45
- digest: string;
46
- executable: string;
47
- commandArgv: string[];
48
- bindings: Record<string, string>;
49
- detail: OpenApeCliAuthorizationDetail;
50
- executionContext: OpenApeExecutionContext;
51
- permission: string;
52
- }
53
- interface ResolvedCapability {
54
- adapter: ShapesAdapter;
55
- source: string;
56
- digest: string;
57
- executable: string;
58
- details: OpenApeCliAuthorizationDetail[];
59
- executionContext: OpenApeExecutionContext;
60
- permissions: string[];
61
- summary: string;
62
- }
63
- interface GrantRequestOptions {
64
- requester: string;
65
- target_host: string;
66
- grant_type: 'once' | 'timed' | 'always';
67
- reason?: string;
68
- run_as?: string;
69
- }
70
- interface BuiltGrantRequest {
71
- request: OpenApeGrantRequest;
72
- }
73
- interface RegistryEntry {
74
- id: string;
75
- name: string;
76
- description: string;
77
- category: string;
78
- tags: string[];
79
- author: string;
80
- executable: string;
81
- min_shapes_version: string;
82
- digest: string;
83
- download_url: string;
84
- }
85
- interface RegistryIndex {
86
- version: number;
87
- generated_at: string;
88
- adapters: RegistryEntry[];
89
- }
90
- interface AdapterMeta {
91
- id: string;
92
- name: string;
93
- description: string;
94
- author: string;
95
- category: string;
96
- tags: string[];
97
- executable: string;
98
- risk_summary?: string;
99
- homepage?: string;
100
- min_shapes_version: string;
101
- }
102
-
103
- declare function resolveAdapterPath(cliId: string, explicitPath?: string): string;
104
- declare function loadAdapter(cliId: string, explicitPath?: string): LoadedAdapter;
105
- /** Try to load an adapter locally, return null instead of throwing when not found. */
106
- declare function tryLoadAdapter(cliId: string, explicitPath?: string): LoadedAdapter | null;
107
-
108
- /**
109
- * Append a single entry to the audit log at ~/.config/apes/audit.jsonl.
110
- * Failures are swallowed — the audit log should never break the actual flow.
111
- */
112
- declare function appendAuditLog(entry: {
113
- action: string;
114
- timestamp?: number;
115
- } & Record<string, unknown>): void;
116
-
117
- /** A parsed shell command string with the executable and its argv extracted. */
118
- interface ParsedShellCommand {
119
- /** The program to run (first token, e.g. "rm") */
120
- executable: string;
121
- /** Remaining tokens after the executable (e.g. ["-f", "/tmp/foo.txt"]) */
122
- argv: string[];
123
- /**
124
- * true if the command contains compound operators (&&, ||, ;, |),
125
- * subshells ($(...)), or backticks. These cannot be safely handled
126
- * by the adapter mode and must fall back to the generic shell grant flow.
127
- */
128
- isCompound: boolean;
129
- /** The original command string for display/logging */
130
- raw: string;
131
- }
132
- /**
133
- * Parse a shell command string like `rm /tmp/foo.txt` or `git commit -m "hello"` into
134
- * its executable and argv. Uses `shell-quote` to handle quoting correctly.
135
- *
136
- * Returns null for empty/whitespace-only input.
137
- */
138
- declare function parseShellCommand(raw: string): ParsedShellCommand | null;
139
- /**
140
- * Extract the command string from an `apes run --shell -- bash -c "…"` argv.
141
- * Returns null if the argv does not follow that shape.
142
- */
143
- declare function extractShellCommandString(command: string[]): string | null;
144
- /**
145
- * Load an adapter for the given CLI id. If the adapter is not installed locally,
146
- * try to fetch it from the shapes registry and auto-install it.
147
- *
148
- * Returns null when no adapter exists in either location, or when any step fails.
149
- * Failures are logged but never thrown — callers should fall back to the generic flow.
150
- */
151
- declare function loadOrInstallAdapter(cliId: string): Promise<LoadedAdapter | null>;
152
-
153
- declare function resolveCapabilityRequest(loaded: LoadedAdapter, params: {
154
- resources: string[];
155
- selectors?: string[];
156
- actions: string[];
157
- }): ResolvedCapability;
158
-
159
- declare function extractWrappedCommand(args: string[]): string[];
160
- declare function extractOption(args: string[], name: string): string | undefined;
1
+ import { ResolvedCommand } from '@openape/shapes';
2
+ export { AdapterMeta, BuiltGrantRequest, GrantRequestOptions, LoadedAdapter, RegistryEntry, RegistryIndex, ResolvedCapability, ResolvedCommand, ShapesAdapter, ShapesOperation, appendAuditLog, buildExactCommandGrantRequest, buildStructuredCliGrantRequest, extractShellCommandString, fetchRegistry, findAdapter, findConflictingAdapters, getInstalledDigest, installAdapter, isInstalled, loadAdapter, loadOrInstallAdapter, parseShellCommand, removeAdapter, resolveAdapterPath, resolveCapabilityRequest, resolveCommand, searchAdapters, tryLoadAdapter } from '@openape/shapes';
3
+ export { ApeShellResult, ChatMessage, RpcSessionMap, RunOptions, RunResult, RunStreamHandlers, RuntimeConfig, TOOLS, ToolDefinition, TraceEntry, runApeShell, runLoop, taskTools } from '@openape/agent-runtime';
161
4
 
162
5
  interface SimilarGrantsInfo {
163
6
  similar_grants: Array<{
@@ -201,41 +44,8 @@ declare function fetchGrantToken(idp: string, grantId: string): Promise<string>;
201
44
  declare function verifyAndExecute(token: string, resolved: ResolvedCommand, grantId?: string): Promise<void>;
202
45
  declare function findExistingGrant(resolved: ResolvedCommand, idp: string): Promise<string | null>;
203
46
 
204
- declare function resolveCommand(loaded: LoadedAdapter, fullArgv: string[]): Promise<ResolvedCommand>;
205
-
206
- declare function buildExactCommandGrantRequest(command: string[], options: GrantRequestOptions & {
207
- audience: string;
208
- }): Promise<BuiltGrantRequest>;
209
- declare function buildStructuredCliGrantRequest(resolved: ResolvedCommand | ResolvedCapability, options: GrantRequestOptions): Promise<BuiltGrantRequest>;
210
-
211
- declare function fetchRegistry(forceRefresh?: boolean): Promise<RegistryIndex>;
212
- declare function searchAdapters(index: RegistryIndex, query: string): RegistryEntry[];
213
- /**
214
- * Look up a registry entry by its id or its executable field. This lets callers
215
- * pass either the registry id ("o365") or the binary name ("o365-cli"); most
216
- * adapters have id === executable, but the two can diverge.
217
- */
218
- declare function findAdapter(index: RegistryIndex, idOrExecutable: string): RegistryEntry | undefined;
219
-
220
- interface InstallResult {
221
- id: string;
222
- path: string;
223
- digest: string;
224
- updated: boolean;
225
- }
226
- declare function installAdapter(entry: RegistryEntry, options?: {
227
- local?: boolean;
228
- }): Promise<InstallResult>;
229
- declare function getInstalledDigest(id: string, local: boolean): string | null;
230
- declare function isInstalled(id: string, local: boolean): boolean;
231
- declare function removeAdapter(id: string, local: boolean): boolean;
232
- interface ConflictingAdapter {
233
- file: string;
234
- path: string;
235
- adapterId: string;
236
- executable: string;
237
- }
238
- declare function findConflictingAdapters(executable: string, excludeId: string): ConflictingAdapter[];
47
+ declare function extractWrappedCommand(args: string[]): string[];
48
+ declare function extractOption(args: string[], name: string): string | undefined;
239
49
 
240
50
  interface AuthData {
241
51
  idp: string;
@@ -348,114 +158,4 @@ declare class CliExit extends Error {
348
158
  constructor(exitCode?: number);
349
159
  }
350
160
 
351
- interface ToolDefinition {
352
- name: string;
353
- description: string;
354
- parameters: Record<string, unknown>;
355
- execute: (args: unknown) => Promise<unknown>;
356
- }
357
- declare const TOOLS: Record<string, ToolDefinition>;
358
- /**
359
- * Resolve a task spec's tool name list to ToolDefinitions. Throws on
360
- * unknown names — callers must surface that as a run-failure with a
361
- * clear "unknown tool: foo" final_message so the owner can see what
362
- * went wrong in the SP UI.
363
- */
364
- declare function taskTools(names: string[]): ToolDefinition[];
365
-
366
- interface ChatMessage {
367
- role: 'system' | 'user' | 'assistant' | 'tool';
368
- content: string | null;
369
- tool_calls?: Array<{
370
- id: string;
371
- type: 'function';
372
- function: {
373
- name: string;
374
- arguments: string;
375
- };
376
- }>;
377
- tool_call_id?: string;
378
- name?: string;
379
- }
380
- interface RuntimeConfig {
381
- apiBase: string;
382
- apiKey: string;
383
- model: string;
384
- }
385
- interface TraceEntry {
386
- step: number;
387
- type: 'assistant' | 'tool_call' | 'tool_result' | 'tool_error';
388
- preview: string;
389
- tool?: string;
390
- }
391
- interface RunResult {
392
- status: 'ok' | 'error';
393
- finalMessage: string | null;
394
- stepCount: number;
395
- trace: TraceEntry[];
396
- }
397
- interface RunStreamHandlers {
398
- onTextDelta?: (delta: string) => void;
399
- onToolCall?: (call: {
400
- name: string;
401
- args: unknown;
402
- }) => void;
403
- onToolResult?: (result: {
404
- name: string;
405
- result: unknown;
406
- }) => void;
407
- onToolError?: (err: {
408
- name: string;
409
- error: string;
410
- }) => void;
411
- onDone?: (result: RunResult) => void;
412
- }
413
- interface RunOptions {
414
- config: RuntimeConfig;
415
- systemPrompt: string;
416
- userMessage: string;
417
- tools: ToolDefinition[];
418
- maxSteps: number;
419
- history?: ChatMessage[];
420
- handlers?: RunStreamHandlers;
421
- fetchImpl?: typeof fetch;
422
- /**
423
- * Send `stream: true` to the LiteLLM proxy and aggregate the SSE
424
- * chunks locally into a single non-stream response. Workaround for
425
- * LiteLLM's chatgpt-OAuth provider whose non-stream `/v1/chat/
426
- * completions` returns an empty body (the chatgpt upstream only
427
- * emits content via the responses-API streaming path; the bridge
428
- * back to chat/completions fails to aggregate). Streaming + local
429
- * aggregation produces a correct response with every provider
430
- * LiteLLM ships, so this flag is safe to enable globally — it
431
- * defaults off only to keep existing JSON-fixture tests intact.
432
- */
433
- streamAggregate?: boolean;
434
- }
435
- declare function runLoop(opts: RunOptions): Promise<RunResult>;
436
- interface RpcSession {
437
- messages: ChatMessage[];
438
- systemPrompt: string;
439
- tools: ToolDefinition[];
440
- maxSteps: number;
441
- lastTouched: number;
442
- }
443
- declare class RpcSessionMap {
444
- private sessions;
445
- get(id: string): RpcSession | undefined;
446
- put(id: string, s: RpcSession): void;
447
- evictStale(): void;
448
- size(): number;
449
- }
450
-
451
- interface ApeShellResult {
452
- stdout: string;
453
- stderr: string;
454
- exit_code: number;
455
- timed_out?: boolean;
456
- error?: string;
457
- hint?: string;
458
- }
459
- declare function runApeShell(cmd: string, timeoutMs?: number): Promise<ApeShellResult>;
460
-
461
- export { type AdapterMeta, type ApeShellResult, type ApesConfig, ApiError, type AuthData, type BuiltGrantRequest, type ChatMessage, CliError, CliExit, type GrantRequestOptions, type LoadedAdapter, type RegistryEntry, type RegistryIndex, type ResolvedCapability, type ResolvedCommand, RpcSessionMap, type RunOptions, type RunResult, type RunStreamHandlers, type RuntimeConfig, type ShapesAdapter, type ShapesOperation, TOOLS, type ToolDefinition, type TraceEntry, apiFetch, appendAuditLog, buildExactCommandGrantRequest, buildStructuredCliGrantRequest, clearAuth, createShapesGrant, discoverEndpoints, extractOption, extractShellCommandString, extractWrappedCommand, fetchGrantToken, fetchRegistry, findAdapter, findConflictingAdapters, findExistingGrant, getAuthToken, getIdpUrl, getInstalledDigest, getRequesterIdentity, installAdapter, isInstalled, loadAdapter, loadAuth, loadConfig, loadOrInstallAdapter, parseDuration, parseShellCommand, removeAdapter, resolveAdapterPath, resolveCapabilityRequest, resolveCommand, runApeShell, runLoop, saveAuth, saveConfig, searchAdapters, taskTools, tryLoadAdapter, verifyAndExecute, waitForGrantStatus };
161
+ export { type ApesConfig, ApiError, type AuthData, CliError, CliExit, apiFetch, clearAuth, createShapesGrant, discoverEndpoints, extractOption, extractWrappedCommand, fetchGrantToken, findExistingGrant, getAuthToken, getIdpUrl, getRequesterIdentity, loadAuth, loadConfig, parseDuration, saveAuth, saveConfig, verifyAndExecute, waitForGrantStatus };
package/dist/index.js CHANGED
@@ -2,41 +2,17 @@
2
2
  import {
3
3
  CliError,
4
4
  CliExit,
5
- RpcSessionMap,
6
- TOOLS,
7
- parseDuration,
8
- runApeShell,
9
- runLoop,
10
- taskTools
11
- } from "./chunk-ZEUSCNCH.js";
5
+ parseDuration
6
+ } from "./chunk-QMMRZPD2.js";
12
7
  import {
13
- appendAuditLog,
14
- buildExactCommandGrantRequest,
15
- buildStructuredCliGrantRequest,
16
8
  createShapesGrant,
17
9
  extractOption,
18
- extractShellCommandString,
19
10
  extractWrappedCommand,
20
11
  fetchGrantToken,
21
- fetchRegistry,
22
- findAdapter,
23
- findConflictingAdapters,
24
12
  findExistingGrant,
25
- getInstalledDigest,
26
- installAdapter,
27
- isInstalled,
28
- loadAdapter,
29
- loadOrInstallAdapter,
30
- parseShellCommand,
31
- removeAdapter,
32
- resolveAdapterPath,
33
- resolveCapabilityRequest,
34
- resolveCommand,
35
- searchAdapters,
36
- tryLoadAdapter,
37
13
  verifyAndExecute,
38
14
  waitForGrantStatus
39
- } from "./chunk-PEA2RDWK.js";
15
+ } from "./chunk-BA2V3BBO.js";
40
16
  import {
41
17
  ApiError,
42
18
  apiFetch,
@@ -52,6 +28,30 @@ import {
52
28
  saveAuth,
53
29
  saveConfig
54
30
  } from "./chunk-OBF7IMQ2.js";
31
+
32
+ // src/index.ts
33
+ import {
34
+ appendAuditLog,
35
+ buildExactCommandGrantRequest,
36
+ buildStructuredCliGrantRequest,
37
+ extractShellCommandString,
38
+ fetchRegistry,
39
+ findAdapter,
40
+ findConflictingAdapters,
41
+ getInstalledDigest,
42
+ installAdapter,
43
+ isInstalled,
44
+ loadAdapter,
45
+ loadOrInstallAdapter,
46
+ parseShellCommand,
47
+ removeAdapter,
48
+ resolveAdapterPath,
49
+ resolveCapabilityRequest,
50
+ resolveCommand,
51
+ searchAdapters,
52
+ tryLoadAdapter
53
+ } from "@openape/shapes";
54
+ import { runLoop, RpcSessionMap, taskTools, TOOLS, runApeShell } from "@openape/agent-runtime";
55
55
  export {
56
56
  ApiError,
57
57
  CliError,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
1
+ {"version":3,"sources":["../src/index.ts"],"sourcesContent":["// Pure shapes library — re-exported from @openape/shapes\nexport {\n appendAuditLog,\n buildExactCommandGrantRequest,\n buildStructuredCliGrantRequest,\n extractShellCommandString,\n fetchRegistry,\n findAdapter,\n findConflictingAdapters,\n getInstalledDigest,\n installAdapter,\n isInstalled,\n loadAdapter,\n loadOrInstallAdapter,\n parseShellCommand,\n removeAdapter,\n resolveAdapterPath,\n resolveCapabilityRequest,\n resolveCommand,\n searchAdapters,\n tryLoadAdapter,\n} from '@openape/shapes'\n\nexport type {\n AdapterMeta,\n BuiltGrantRequest,\n GrantRequestOptions,\n LoadedAdapter,\n RegistryEntry,\n RegistryIndex,\n ResolvedCapability,\n ResolvedCommand,\n ShapesAdapter,\n ShapesOperation,\n} from '@openape/shapes'\n\n// Grant-orchestration + CLI glue — stayed in apes\nexport { createShapesGrant, fetchGrantToken, findExistingGrant, verifyAndExecute, waitForGrantStatus } from './shapes/grants.js'\nexport { extractOption, extractWrappedCommand } from './shapes/commands/explain.js'\n\n// Apes-specific exports\nexport { loadAuth, saveAuth, clearAuth, loadConfig, saveConfig, getIdpUrl, getAuthToken, getRequesterIdentity } from './config'\nexport type { AuthData, ApesConfig } from './config'\nexport { apiFetch, discoverEndpoints, ApiError } from './http'\nexport { parseDuration } from './duration'\nexport { CliError, CliExit } from './errors'\n\n// Agent-runtime: callable in-process from the chat-bridge so it doesn't\n// need to spawn `apes agents serve --rpc` per turn. Same loop the\n// stdio-RPC server runs internally — see commands/agents/serve.ts.\nexport { runLoop, RpcSessionMap, taskTools, TOOLS, runApeShell } from '@openape/agent-runtime'\nexport type {\n ChatMessage,\n RunOptions,\n RunResult,\n RuntimeConfig,\n RunStreamHandlers,\n TraceEntry,\n ToolDefinition,\n ApeShellResult,\n} from '@openape/agent-runtime'\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,OACK;AA6BP,SAAS,SAAS,eAAe,WAAW,OAAO,mBAAmB;","names":[]}
@@ -3,18 +3,20 @@ import {
3
3
  checkSudoRejection,
4
4
  isApesSelfDispatch,
5
5
  notifyGrantPending
6
- } from "./chunk-3COOEDPF.js";
6
+ } from "./chunk-RVAXRDC2.js";
7
7
  import {
8
8
  appendAuditLog,
9
+ loadOrInstallAdapter,
10
+ parseShellCommand,
11
+ resolveCommand
12
+ } from "./chunk-JXS3KLJ5.js";
13
+ import {
9
14
  createShapesGrant,
10
15
  fetchGrantToken,
11
16
  findExistingGrant,
12
- loadOrInstallAdapter,
13
- parseShellCommand,
14
- resolveCommand,
15
17
  verifyAndConsume,
16
18
  waitForGrantStatus
17
- } from "./chunk-PEA2RDWK.js";
19
+ } from "./chunk-BA2V3BBO.js";
18
20
  import {
19
21
  apiFetch,
20
22
  getGrantsEndpoint
@@ -777,4 +779,4 @@ async function runInteractiveShell() {
777
779
  export {
778
780
  runInteractiveShell
779
781
  };
780
- //# sourceMappingURL=orchestrator-REICEX3F.js.map
782
+ //# sourceMappingURL=orchestrator-P7QFDBBK.js.map