@heddleagent/execution-host-client 6.7.0 → 8.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/README.md +54 -35
- package/dist/agentcore/agentcore-execution-host.d.ts +1 -1
- package/dist/agentcore/agentcore-execution-host.d.ts.map +1 -1
- package/dist/agentcore/agentcore-execution-host.js +6 -3
- package/dist/agentcore/agentcore-execution-host.js.map +1 -1
- package/dist/cli/hostctl.d.ts +11 -0
- package/dist/cli/hostctl.d.ts.map +1 -0
- package/dist/cli/hostctl.js +49 -0
- package/dist/cli/hostctl.js.map +1 -0
- package/dist/contracts/index.d.ts +18 -1
- package/dist/contracts/index.d.ts.map +1 -1
- package/dist/contracts/index.js +28 -1
- package/dist/contracts/index.js.map +1 -1
- package/dist/conversation/hosted-conversation-turn-service.js +2 -2
- package/dist/conversation/hosted-conversation-turn-service.js.map +1 -1
- package/dist/conversation/types.d.ts +2 -2
- package/dist/conversation/types.d.ts.map +1 -1
- package/dist/conversation/types.js.map +1 -1
- package/dist/coordinator/contracts.d.ts +148 -5
- package/dist/coordinator/contracts.d.ts.map +1 -1
- package/dist/coordinator/contracts.js +74 -3
- package/dist/coordinator/contracts.js.map +1 -1
- package/dist/coordinator/hosted-heartbeat-execution-client.d.ts +30 -0
- package/dist/coordinator/hosted-heartbeat-execution-client.d.ts.map +1 -0
- package/dist/coordinator/hosted-heartbeat-execution-client.js +240 -0
- package/dist/coordinator/hosted-heartbeat-execution-client.js.map +1 -0
- package/dist/coordinator/hosted-heartbeat-execution-service.d.ts +14 -0
- package/dist/coordinator/hosted-heartbeat-execution-service.d.ts.map +1 -0
- package/dist/coordinator/hosted-heartbeat-execution-service.js +100 -0
- package/dist/coordinator/hosted-heartbeat-execution-service.js.map +1 -0
- package/dist/coordinator/index.d.ts +5 -5
- package/dist/coordinator/index.d.ts.map +1 -1
- package/dist/coordinator/index.js +3 -3
- package/dist/coordinator/index.js.map +1 -1
- package/dist/coordinator/node/execution-http-service.d.ts +11 -0
- package/dist/coordinator/node/execution-http-service.d.ts.map +1 -0
- package/dist/coordinator/node/{delegation-http-service.js → execution-http-service.js} +52 -39
- package/dist/coordinator/node/execution-http-service.js.map +1 -0
- package/dist/coordinator/node/index.d.ts +2 -2
- package/dist/coordinator/node/index.d.ts.map +1 -1
- package/dist/coordinator/node/index.js +1 -1
- package/dist/coordinator/node/index.js.map +1 -1
- package/dist/coordinator/node/types.d.ts +10 -9
- package/dist/coordinator/node/types.d.ts.map +1 -1
- package/dist/coordinator/node/types.js.map +1 -1
- package/dist/coordinator/types.d.ts +51 -13
- package/dist/coordinator/types.d.ts.map +1 -1
- package/dist/coordinator/types.js.map +1 -1
- package/dist/heartbeat/hosted-heartbeat-task-service.js +2 -2
- package/dist/heartbeat/hosted-heartbeat-task-service.js.map +1 -1
- package/dist/host/jwt-execution-host-mcp-capability-verifier.d.ts.map +1 -1
- package/dist/host/jwt-execution-host-mcp-capability-verifier.js +4 -2
- package/dist/host/jwt-execution-host-mcp-capability-verifier.js.map +1 -1
- package/dist/host/jwt-execution-identity-verifier.d.ts.map +1 -1
- package/dist/host/jwt-execution-identity-verifier.js +4 -2
- package/dist/host/jwt-execution-identity-verifier.js.map +1 -1
- package/dist/host/runtime-session/service.d.ts +2 -2
- package/dist/host/runtime-session/service.d.ts.map +1 -1
- package/dist/host/runtime-session/service.js +1 -1
- package/dist/host/runtime-session/service.js.map +1 -1
- package/dist/host/runtime-session/types.d.ts +2 -2
- package/dist/host/runtime-session/types.d.ts.map +1 -1
- package/dist/host/runtime-session/types.js.map +1 -1
- package/dist/host/schemas.d.ts +6 -0
- package/dist/host/schemas.d.ts.map +1 -1
- package/dist/host/schemas.js +18 -1
- package/dist/host/schemas.js.map +1 -1
- package/dist/host/types.d.ts +2 -0
- package/dist/host/types.d.ts.map +1 -1
- package/dist/host/types.js.map +1 -1
- package/dist/http-sse/direct-http-execution-host.d.ts.map +1 -1
- package/dist/http-sse/direct-http-execution-host.js +8 -7
- package/dist/http-sse/direct-http-execution-host.js.map +1 -1
- package/dist/http-sse/types.d.ts +5 -3
- package/dist/http-sse/types.d.ts.map +1 -1
- package/dist/http-sse/types.js.map +1 -1
- package/dist/node/authority-key.d.ts.map +1 -1
- package/dist/node/authority-key.js +24 -49
- package/dist/node/authority-key.js.map +1 -1
- package/dist/node/direct-credentials.d.ts +3 -7
- package/dist/node/direct-credentials.d.ts.map +1 -1
- package/dist/node/direct-credentials.js +3 -15
- package/dist/node/direct-credentials.js.map +1 -1
- package/dist/node/environment-value.d.ts +17 -0
- package/dist/node/environment-value.d.ts.map +1 -0
- package/dist/node/environment-value.js +78 -0
- package/dist/node/environment-value.js.map +1 -0
- package/dist/node/index.d.ts +4 -0
- package/dist/node/index.d.ts.map +1 -1
- package/dist/node/index.js +2 -0
- package/dist/node/index.js.map +1 -1
- package/dist/node/local-credential-bundle.d.ts +33 -0
- package/dist/node/local-credential-bundle.d.ts.map +1 -0
- package/dist/node/local-credential-bundle.js +196 -0
- package/dist/node/local-credential-bundle.js.map +1 -0
- package/dist/node/owner-only-file.d.ts +17 -0
- package/dist/node/owner-only-file.d.ts.map +1 -0
- package/dist/node/owner-only-file.js +59 -0
- package/dist/node/owner-only-file.js.map +1 -0
- package/dist/testing/request.d.ts.map +1 -1
- package/dist/testing/request.js +14 -4
- package/dist/testing/request.js.map +1 -1
- package/package.json +5 -1
- package/spec/v1/openapi.json +62 -4
- package/spec/v1/schema-bundle.json +58 -0
- package/dist/coordinator/hosted-heartbeat-delegation-client.d.ts +0 -21
- package/dist/coordinator/hosted-heartbeat-delegation-client.d.ts.map +0 -1
- package/dist/coordinator/hosted-heartbeat-delegation-client.js +0 -117
- package/dist/coordinator/hosted-heartbeat-delegation-client.js.map +0 -1
- package/dist/coordinator/hosted-heartbeat-delegation-service.d.ts +0 -15
- package/dist/coordinator/hosted-heartbeat-delegation-service.d.ts.map +0 -1
- package/dist/coordinator/hosted-heartbeat-delegation-service.js +0 -81
- package/dist/coordinator/hosted-heartbeat-delegation-service.js.map +0 -1
- package/dist/coordinator/node/delegation-http-service.d.ts +0 -11
- package/dist/coordinator/node/delegation-http-service.d.ts.map +0 -1
- package/dist/coordinator/node/delegation-http-service.js.map +0 -1
package/README.md
CHANGED
|
@@ -5,8 +5,8 @@ invoke a separately deployed Heddle Execution Host. It lets an
|
|
|
5
5
|
adopter keep its own language stack, authentication, database, product policy,
|
|
6
6
|
MCP tools, and UI while reusing the security-sensitive v1 contract machinery.
|
|
7
7
|
|
|
8
|
-
> **Current availability:**
|
|
9
|
-
>
|
|
8
|
+
> **Current availability:** package availability is published through the
|
|
9
|
+
> repository release process. The former
|
|
10
10
|
> `@roackb2/heddle-adopter@5.13.0` coordinate is deprecated and remains
|
|
11
11
|
> installable only for existing consumers. The compatible Execution Host source
|
|
12
12
|
> is maintained in this private-first repository; Heddle does not yet offer a
|
|
@@ -39,7 +39,7 @@ modular AWS SDK for its AgentCore transport and the official MCP SDK, plus
|
|
|
39
39
|
| `@heddleagent/execution-host-client/authority` | ES256 execution assertion and optional MCP capability issuance plus public JWKS projection |
|
|
40
40
|
| `@heddleagent/execution-host-client/conversation` | Turn orchestration across authority, model credentials, optional MCP policy, an `ExecutionHost`, and an optional adopter-implemented durable lifecycle store |
|
|
41
41
|
| `@heddleagent/execution-host-client/heartbeat` | Remote heartbeat orchestration that keeps durable task authority in a coordinator while a compatible Execution Host runs the agent cycle |
|
|
42
|
-
| `@heddleagent/execution-host-client/coordinator` | Authenticated task publication, pause-first desired-state reconciliation, product
|
|
42
|
+
| `@heddleagent/execution-host-client/coordinator` | Authenticated task publication, pause-first desired-state reconciliation, product-work preparation and settlement, and delegated heartbeat execution |
|
|
43
43
|
| `@heddleagent/execution-host-client/coordinator/node` | Standard authenticated Node HTTP edge for product-owned heartbeat authorization |
|
|
44
44
|
| `@heddleagent/execution-host-client/mcp` | Independent capability verification at the adopter's MCP edge |
|
|
45
45
|
| `@heddleagent/execution-host-client/mcp/node` | Stateless official-SDK Streamable HTTP lifecycle around adopter-defined toolsets |
|
|
@@ -47,7 +47,7 @@ modular AWS SDK for its AgentCore transport and the official MCP SDK, plus
|
|
|
47
47
|
| `@heddleagent/execution-host-client/agentcore` | Canonical AgentCore deployment-target validation plus the official AWS AgentCore/SigV4 implementation of the conversation and heartbeat ports |
|
|
48
48
|
| `@heddleagent/execution-host-client/host` | Invocation-bound authority verification plus provider-neutral Runtime-session scope binding, admission, deadlines, cancellation, status, and workflow dispatch shared by compatible Execution Host implementations |
|
|
49
49
|
| `@heddleagent/execution-host-client/testing` | Node-only loopback v1 fixture plus durable-turn store conformance for real adapters |
|
|
50
|
-
| `@heddleagent/execution-host-client/node` | Optional Node JWKS/conversation HTTP edge
|
|
50
|
+
| `@heddleagent/execution-host-client/node` | Optional Node JWKS/conversation HTTP edge, conventional `NAME_FILE` loading, safe local signing-key helpers, and the local credential-bundle initializer used by `heddle-hostctl` |
|
|
51
51
|
|
|
52
52
|
Non-TypeScript adopters can consume the versioned
|
|
53
53
|
[`spec/v1`](spec/v1/README.md) OpenAPI 3.1.1 document, JSON Schema bundle, and
|
|
@@ -176,6 +176,17 @@ owner-only JWK without overwriting an existing file. The loader imports its
|
|
|
176
176
|
private key as non-exportable. Production KMS/HSM or secret-manager storage,
|
|
177
177
|
rotation, revocation, and Windows ACL policy still belong to deployment.
|
|
178
178
|
|
|
179
|
+
For a complete local hosted-service composition, install the package's narrow
|
|
180
|
+
operator CLI and initialize one generic credential bundle:
|
|
181
|
+
|
|
182
|
+
```bash
|
|
183
|
+
heddle-hostctl credentials init --output .local/heddle-credentials
|
|
184
|
+
```
|
|
185
|
+
|
|
186
|
+
The command owns only credential generation and bundle validation. The adopter
|
|
187
|
+
deployment owns Compose or Helm, ports, URLs, database and model inputs,
|
|
188
|
+
migration ordering, service lifecycle, and secret-file mounting.
|
|
189
|
+
|
|
179
190
|
## Verify product authority again at MCP
|
|
180
191
|
|
|
181
192
|
The adopter MCP service must independently verify the bearer. Do not trust
|
|
@@ -330,7 +341,12 @@ for await (const event of host.streamConversationTurn({
|
|
|
330
341
|
prompt: 'Summarize the relevant product state.',
|
|
331
342
|
executionAssertion: issued.executionAssertion(),
|
|
332
343
|
mcpCapability: issued.mcpCapability(),
|
|
333
|
-
|
|
344
|
+
modelCredential: {
|
|
345
|
+
type: 'oauth-access-token',
|
|
346
|
+
provider: 'openai',
|
|
347
|
+
accessToken,
|
|
348
|
+
expiresAt,
|
|
349
|
+
},
|
|
334
350
|
})) {
|
|
335
351
|
applyExecutionEvent(event)
|
|
336
352
|
}
|
|
@@ -342,18 +358,19 @@ terminal event until clean EOF. It never retries an ambiguous invocation.
|
|
|
342
358
|
|
|
343
359
|
## Connect a product to the heartbeat coordinator
|
|
344
360
|
|
|
345
|
-
The product publishes
|
|
346
|
-
|
|
347
|
-
session derivation, short-lived
|
|
361
|
+
The product publishes desired task state and owns a durable product-work
|
|
362
|
+
lifecycle around each Coordinator execution. Heddle owns the coordinator
|
|
363
|
+
protocol, safe reconciliation order, Runtime-session derivation, short-lived
|
|
364
|
+
authority bundle, and execution composition.
|
|
348
365
|
|
|
349
366
|
```ts
|
|
350
367
|
import {
|
|
351
368
|
HostedHeartbeatCoordinatorClient,
|
|
352
|
-
|
|
369
|
+
HostedHeartbeatExecutionService,
|
|
353
370
|
HostedHeartbeatTaskReconciler,
|
|
354
371
|
} from '@heddleagent/execution-host-client/coordinator'
|
|
355
372
|
import {
|
|
356
|
-
|
|
373
|
+
NodeHostedHeartbeatExecutionHttpService,
|
|
357
374
|
} from '@heddleagent/execution-host-client/coordinator/node'
|
|
358
375
|
|
|
359
376
|
const coordinator = new HostedHeartbeatCoordinatorClient({
|
|
@@ -365,30 +382,31 @@ await new HostedHeartbeatTaskReconciler({ coordinator }).reconcile({
|
|
|
365
382
|
resume: backgroundChecksEnabled,
|
|
366
383
|
})
|
|
367
384
|
|
|
368
|
-
const
|
|
385
|
+
const executions = new HostedHeartbeatExecutionService({
|
|
369
386
|
authority,
|
|
370
387
|
runtimeSessionNamespace: 'example-product',
|
|
371
388
|
maxExecutionMs: 300_000,
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
389
|
+
lifecycle: {
|
|
390
|
+
prepare: ({ taskId, executionId, signal }) =>
|
|
391
|
+
productWork.claim({ taskId, executionId, signal }),
|
|
392
|
+
settle: (result) => productWork.settle(result),
|
|
375
393
|
},
|
|
376
394
|
})
|
|
377
|
-
const
|
|
378
|
-
|
|
379
|
-
apiToken:
|
|
395
|
+
const executionHttp = new NodeHostedHeartbeatExecutionHttpService({
|
|
396
|
+
executions,
|
|
397
|
+
apiToken: coordinatorProductExecutionToken,
|
|
380
398
|
})
|
|
381
399
|
```
|
|
382
400
|
|
|
383
401
|
`projectDesiredHeartbeatTasks` remains product-owned because it translates
|
|
384
|
-
product records into desired Heddle tasks.
|
|
385
|
-
product-owned because it
|
|
386
|
-
authorized tenant/subject/product-session scope and exact MCP tool set
|
|
387
|
-
|
|
388
|
-
|
|
402
|
+
product records into desired Heddle tasks. The product lifecycle remains
|
|
403
|
+
product-owned because it claims a fixed work horizon, returns only the
|
|
404
|
+
authorized tenant/subject/product-session scope and exact MCP tool set, and
|
|
405
|
+
validates durable effects before accepting completion. Product code does not
|
|
406
|
+
construct coordinator requests, Runtime-session IDs, deadlines, or JWTs.
|
|
389
407
|
|
|
390
408
|
The Node handler can be mounted before an existing router through
|
|
391
|
-
`
|
|
409
|
+
`executionHttp.handle(request, response)`. See the
|
|
392
410
|
[coordinator boundary](src/coordinator/README.md) for the corresponding
|
|
393
411
|
coordinator-side client and execution transport.
|
|
394
412
|
|
|
@@ -397,29 +415,30 @@ coordinator-side client and execution transport.
|
|
|
397
415
|
For autonomous work, keep the durable task store and scheduler in one
|
|
398
416
|
long-running coordinator. Inject the hosted transport only at the point where
|
|
399
417
|
the scheduler would otherwise run the local heartbeat agent. The coordinator
|
|
400
|
-
uses the product
|
|
401
|
-
keys or reimplementing its authority shape:
|
|
418
|
+
uses the product execution-lifecycle endpoint rather than receiving product
|
|
419
|
+
signing keys or reimplementing its authority shape:
|
|
402
420
|
|
|
403
421
|
```ts
|
|
404
422
|
import { HeartbeatSchedulerService } from '@heddleagent/runtime/advanced'
|
|
405
423
|
import {
|
|
406
|
-
|
|
407
|
-
|
|
424
|
+
HostedHeartbeatDelegatedExecution,
|
|
425
|
+
HostedHeartbeatExecutionClient,
|
|
408
426
|
} from '@heddleagent/execution-host-client/coordinator'
|
|
409
427
|
|
|
410
|
-
const
|
|
428
|
+
const executions = new HostedHeartbeatExecutionClient({
|
|
411
429
|
baseUrl: productBackendUrl,
|
|
412
|
-
apiToken:
|
|
430
|
+
apiToken: productExecutionToken,
|
|
413
431
|
})
|
|
414
|
-
const
|
|
415
|
-
|
|
432
|
+
const delegatedExecution = new HostedHeartbeatDelegatedExecution({
|
|
433
|
+
executions,
|
|
416
434
|
executionHost: agentCoreExecutionHost,
|
|
417
435
|
modelCredentials,
|
|
418
436
|
})
|
|
419
437
|
|
|
420
438
|
const scheduler = HeartbeatSchedulerService.start({
|
|
421
439
|
store: heddleHeartbeatStore,
|
|
422
|
-
|
|
440
|
+
handler: (context) => delegatedExecution.handle(context),
|
|
441
|
+
agentExecutionTransport: delegatedExecution,
|
|
423
442
|
})
|
|
424
443
|
```
|
|
425
444
|
|
|
@@ -427,9 +446,9 @@ The coordinator still owns task lookup, claims, checkpoint loading,
|
|
|
427
446
|
cancellation, claim-fenced settlement, history, and recovery. The Runtime
|
|
428
447
|
receives a bounded task/checkpoint request plus invocation-scoped authority and
|
|
429
448
|
model credentials; it receives no Heddle database credential. Omitting
|
|
430
|
-
|
|
431
|
-
level `/heartbeat` composition remains available for deployments
|
|
432
|
-
|
|
449
|
+
the hosted execution composition preserves the existing in-process runner.
|
|
450
|
+
The lower-level `/heartbeat` composition remains available for deployments
|
|
451
|
+
whose Coordinator and product authority live in the same process.
|
|
433
452
|
|
|
434
453
|
## Verify an adopter integration locally
|
|
435
454
|
|
|
@@ -12,6 +12,6 @@ export declare class AgentCoreExecutionHost implements ExecutionHost, HeartbeatE
|
|
|
12
12
|
streamHeartbeatTask(input: ExecutionHostHeartbeatTask): AsyncIterable<ExecutionHostHeartbeatStreamEvent>;
|
|
13
13
|
close(): void;
|
|
14
14
|
}
|
|
15
|
-
export declare const AGENTCORE_FORWARDED_HEADER_NAMES: readonly ["x-heddle-execution-host-assertion", "x-heddle-execution-host-mcp-capability", "x-heddle-execution-host-model-
|
|
15
|
+
export declare const AGENTCORE_FORWARDED_HEADER_NAMES: readonly ["x-heddle-execution-host-assertion", "x-heddle-execution-host-mcp-capability", "x-heddle-execution-host-model-credential"];
|
|
16
16
|
export declare const AGENTCORE_EXCLUDED_HEADER_NAMES: readonly ["x-heddle-execution-host-local-token"];
|
|
17
17
|
//# sourceMappingURL=agentcore-execution-host.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentcore-execution-host.d.ts","sourceRoot":"","sources":["../../src/agentcore/agentcore-execution-host.ts"],"names":[],"mappings":"AAMA,OAAO,EAML,KAAK,iCAAiC,EACtC,KAAK,wBAAwB,EAC9B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,4BAA4B,EAE7B,MAAM,YAAY,CAAC;AAqBpB;;;GAGG;AACH,qBAAa,sBACb,YAAW,aAAa,EAAE,sBAAsB;;gBAMlC,MAAM,EAAE,4BAA4B;IAkBhD,sBAAsB,CACpB,KAAK,EAAE,6BAA6B,GACnC,aAAa,CAAC,wBAAwB,CAAC;IAK1C,mBAAmB,CACjB,KAAK,EAAE,0BAA0B,GAChC,aAAa,CAAC,iCAAiC,CAAC;IAKnD,KAAK,IAAI,IAAI;
|
|
1
|
+
{"version":3,"file":"agentcore-execution-host.d.ts","sourceRoot":"","sources":["../../src/agentcore/agentcore-execution-host.ts"],"names":[],"mappings":"AAMA,OAAO,EAML,KAAK,iCAAiC,EACtC,KAAK,wBAAwB,EAC9B,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAEL,KAAK,aAAa,EAClB,KAAK,6BAA6B,EAClC,KAAK,0BAA0B,EAC/B,KAAK,sBAAsB,EAC5B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,KAAK,EACV,4BAA4B,EAE7B,MAAM,YAAY,CAAC;AAqBpB;;;GAGG;AACH,qBAAa,sBACb,YAAW,aAAa,EAAE,sBAAsB;;gBAMlC,MAAM,EAAE,4BAA4B;IAkBhD,sBAAsB,CACpB,KAAK,EAAE,6BAA6B,GACnC,aAAa,CAAC,wBAAwB,CAAC;IAK1C,mBAAmB,CACjB,KAAK,EAAE,0BAA0B,GAChC,aAAa,CAAC,iCAAiC,CAAC;IAKnD,KAAK,IAAI,IAAI;CAoEd;AAsGD,eAAO,MAAM,gCAAgC,sIAIlC,CAAC;AAEZ,eAAO,MAAM,+BAA+B,kDAEjC,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { BedrockAgentCoreClient, InvokeAgentRuntimeCommand, } from '@aws-sdk/client-bedrock-agentcore';
|
|
2
2
|
import { HttpRequest } from '@smithy/protocol-http';
|
|
3
|
-
import { AGENTCORE_RUNTIME_SESSION_HEADER, EXECUTION_ASSERTION_HEADER, EXECUTION_HOST_LOCAL_TOKEN_HEADER, MCP_CAPABILITY_HEADER,
|
|
3
|
+
import { AGENTCORE_RUNTIME_SESSION_HEADER, EXECUTION_ASSERTION_HEADER, EXECUTION_HOST_LOCAL_TOKEN_HEADER, MCP_CAPABILITY_HEADER, MODEL_CREDENTIAL_HEADER, } from '../contracts/index.js';
|
|
4
4
|
import { DirectHttpExecutionHost, } from '../http-sse/index.js';
|
|
5
5
|
import { AgentCoreExecutionTargetSchema } from './schemas.js';
|
|
6
6
|
const CONTENT_TYPE = 'application/json';
|
|
@@ -68,7 +68,10 @@ export class AgentCoreExecutionHost {
|
|
|
68
68
|
EXECUTION_ASSERTION_HEADER,
|
|
69
69
|
requireHeader(headers, EXECUTION_ASSERTION_HEADER),
|
|
70
70
|
],
|
|
71
|
-
[
|
|
71
|
+
[
|
|
72
|
+
MODEL_CREDENTIAL_HEADER,
|
|
73
|
+
requireHeader(headers, MODEL_CREDENTIAL_HEADER),
|
|
74
|
+
],
|
|
72
75
|
...(headers.has(MCP_CAPABILITY_HEADER)
|
|
73
76
|
? [[MCP_CAPABILITY_HEADER, headers.get(MCP_CAPABILITY_HEADER)]]
|
|
74
77
|
: []),
|
|
@@ -196,7 +199,7 @@ function readErrorName(error) {
|
|
|
196
199
|
export const AGENTCORE_FORWARDED_HEADER_NAMES = Object.freeze([
|
|
197
200
|
EXECUTION_ASSERTION_HEADER,
|
|
198
201
|
MCP_CAPABILITY_HEADER,
|
|
199
|
-
|
|
202
|
+
MODEL_CREDENTIAL_HEADER,
|
|
200
203
|
]);
|
|
201
204
|
export const AGENTCORE_EXCLUDED_HEADER_NAMES = Object.freeze([
|
|
202
205
|
EXECUTION_HOST_LOCAL_TOKEN_HEADER,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"agentcore-execution-host.js","sourceRoot":"","sources":["../../src/agentcore/agentcore-execution-host.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,yBAAyB,GAE1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,gCAAgC,EAChC,0BAA0B,EAC1B,iCAAiC,EACjC,qBAAqB,EACrB,oBAAoB,GAGrB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,uBAAuB,GAKxB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,YAAY,GAAG,kBAAkB,CAAC;AACxC,MAAM,MAAM,GAAG,mBAAmB,CAAC;AACnC,MAAM,6BAA6B,GAAG,EAAE,CAAC;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AK,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,UAAU,CACrD,CAAC;AACJ,CAAC;AAED,SAAS,iBAAiB,CAAC,KAAc;IACvC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,WAAW,IAAI,KAAK,CAAC,EAAE,CAAC;QACnE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,QAAQ,GAAI,KAAsD;SACrE,SAAS,CAAC;IACb,MAAM,MAAM,GAAG,QAAQ,EAAE,cAAc,CAAC;IACxC,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG;QACjE,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5D,0BAA0B;IAC1B,qBAAqB;IACrB,oBAAoB;CACZ,CAAC,CAAC;AAEZ,MAAM,CAAC,MAAM,+BAA+B,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3D,iCAAiC;CACzB,CAAC,CAAC","sourcesContent":["import {\n BedrockAgentCoreClient,\n InvokeAgentRuntimeCommand,\n type InvokeAgentRuntimeCommandOutput,\n} from '@aws-sdk/client-bedrock-agentcore';\nimport { HttpRequest } from '@smithy/protocol-http';\nimport {\n AGENTCORE_RUNTIME_SESSION_HEADER,\n EXECUTION_ASSERTION_HEADER,\n EXECUTION_HOST_LOCAL_TOKEN_HEADER,\n MCP_CAPABILITY_HEADER,\n MODEL_API_KEY_HEADER,\n type ExecutionHostHeartbeatStreamEvent,\n type ExecutionHostStreamEvent,\n} from '../contracts/index.js';\nimport {\n DirectHttpExecutionHost,\n type ExecutionHost,\n type ExecutionHostConversationTurn,\n type ExecutionHostHeartbeatTask,\n type HeartbeatExecutionHost,\n} from '../http-sse/index.js';\nimport type {\n AgentCoreExecutionHostConfig,\n AgentCoreRuntimeClient,\n} from './types.js';\nimport { AgentCoreExecutionTargetSchema } from './schemas.js';\n\nconst CONTENT_TYPE = 'application/json';\nconst ACCEPT = 'text/event-stream';\nconst MIN_RUNTIME_SESSION_ID_LENGTH = 33;\nconst MAX_RUNTIME_SESSION_ID_LENGTH = 256;\nconst RUNTIME_SESSION_ID_PATTERN = /^[A-Za-z0-9](?:-*[A-Za-z0-9])+$/;\nconst WIRE_BRIDGE_URL = new URL('http://127.0.0.1/agentcore-bridge');\nconst NON_FORWARDED_LOCAL_TOKEN = 'agentcore-bridge-token-never-forwarded';\nconst SERVICE_ERROR_CODES = new Map<string, string>([\n ['AccessDeniedException', 'access_denied'],\n ['InternalServerException', 'runtime_internal'],\n ['ResourceNotFoundException', 'runtime_not_found'],\n ['RetryableConflictException', 'runtime_conflict'],\n ['RuntimeClientError', 'runtime_client_error'],\n ['ServiceQuotaExceededException', 'quota_exceeded'],\n ['ThrottlingException', 'throttled'],\n ['ValidationException', 'invalid_request'],\n]);\n\n/**\n * Invokes one compatible Heddle Execution Host through AWS AgentCore while\n * reusing the package's strict request and SSE protocol validation.\n */\nexport class AgentCoreExecutionHost\nimplements ExecutionHost, HeartbeatExecutionHost {\n readonly #client: AgentCoreRuntimeClient;\n readonly #runtimeArn: string;\n readonly #qualifier?: string;\n readonly #wire: DirectHttpExecutionHost;\n\n constructor(config: AgentCoreExecutionHostConfig) {\n const { client, ...rawTarget } = config;\n const target = AgentCoreExecutionTargetSchema.parse(rawTarget);\n this.#runtimeArn = target.runtimeArn;\n this.#qualifier = target.qualifier;\n this.#client = client ?? new BedrockAgentCoreClient({\n region: target.region,\n // Invocation settlement is ambiguous after a transport interruption.\n // Product policy, not the AWS client, decides whether a turn may retry.\n maxAttempts: 1,\n });\n this.#wire = new DirectHttpExecutionHost({\n baseUrl: WIRE_BRIDGE_URL,\n localToken: NON_FORWARDED_LOCAL_TOKEN,\n fetch: (_input, init) => this.#invoke(init),\n });\n }\n\n streamConversationTurn(\n input: ExecutionHostConversationTurn,\n ): AsyncIterable<ExecutionHostStreamEvent> {\n assertAgentCoreRuntimeSessionId(input.runtimeSessionId);\n return this.#wire.streamConversationTurn(input);\n }\n\n streamHeartbeatTask(\n input: ExecutionHostHeartbeatTask,\n ): AsyncIterable<ExecutionHostHeartbeatStreamEvent> {\n assertAgentCoreRuntimeSessionId(input.runtimeSessionId);\n return this.#wire.streamHeartbeatTask(input);\n }\n\n close(): void {\n this.#client.destroy?.();\n }\n\n async #invoke(init?: RequestInit): Promise<Response> {\n if (init?.method !== 'POST' || typeof init.body !== 'string') {\n throw new Error('AgentCore wire bridge received an invalid request.');\n }\n const headers = new Headers(init.headers);\n const runtimeSessionId = requireHeader(\n headers,\n AGENTCORE_RUNTIME_SESSION_HEADER,\n );\n const customHeaders = Object.fromEntries([\n [\n EXECUTION_ASSERTION_HEADER,\n requireHeader(headers, EXECUTION_ASSERTION_HEADER),\n ],\n [MODEL_API_KEY_HEADER, requireHeader(headers, MODEL_API_KEY_HEADER)],\n ...(headers.has(MCP_CAPABILITY_HEADER)\n ? [[MCP_CAPABILITY_HEADER, headers.get(MCP_CAPABILITY_HEADER)!]]\n : []),\n ]);\n const command = new InvokeAgentRuntimeCommand({\n agentRuntimeArn: this.#runtimeArn,\n runtimeSessionId,\n qualifier: this.#qualifier,\n contentType: CONTENT_TYPE,\n accept: ACCEPT,\n payload: new TextEncoder().encode(init.body),\n });\n addSignedCustomHeaders(command, customHeaders);\n const signal = init.signal ?? undefined;\n\n try {\n const output = await this.#client.send(command, { abortSignal: signal });\n return new Response(\n output.response ? toReadableStream(output.response) : null,\n {\n status: output.statusCode ?? output.$metadata.httpStatusCode ?? 200,\n headers: {\n 'content-type': output.contentType ?? 'application/octet-stream',\n },\n },\n );\n } catch (error) {\n if (signal?.aborted) {\n throw error;\n }\n const status = readServiceStatus(error);\n if (!status) {\n throw error;\n }\n const code = SERVICE_ERROR_CODES.get(readErrorName(error)) ?? 'unknown';\n return new Response(JSON.stringify({\n error: {\n code,\n message: 'AgentCore rejected the invocation.',\n },\n }), {\n status,\n headers: { 'content-type': CONTENT_TYPE },\n });\n }\n }\n}\n\nfunction assertAgentCoreRuntimeSessionId(value: string): void {\n if (\n value.length < MIN_RUNTIME_SESSION_ID_LENGTH\n || value.length > MAX_RUNTIME_SESSION_ID_LENGTH\n || !RUNTIME_SESSION_ID_PATTERN.test(value)\n ) {\n throw new Error('AgentCore runtime session ID is not provider-compatible.');\n }\n}\n\nfunction addSignedCustomHeaders(\n command: InvokeAgentRuntimeCommand,\n headers: Readonly<Record<string, string>>,\n): void {\n command.middlewareStack.add(\n (next) => async (args) => {\n if (!HttpRequest.isInstance(args.request)) {\n throw new Error('AgentCore invocation did not produce an HTTP request.');\n }\n Object.assign(args.request.headers, headers);\n return await next(args);\n },\n {\n step: 'build',\n priority: 'low',\n name: 'heddleAgentCoreCustomHeaders',\n },\n );\n}\n\nfunction requireHeader(headers: Headers, name: string): string {\n const value = headers.get(name);\n if (!value) {\n throw new Error('AgentCore wire bridge omitted required authority.');\n }\n return value;\n}\n\nfunction toReadableStream(\n source: NonNullable<InvokeAgentRuntimeCommandOutput['response']>,\n): ReadableStream<Uint8Array> {\n if (source instanceof Blob) {\n return source.stream();\n }\n if (source instanceof ReadableStream) {\n return source;\n }\n if (!isAsyncIterable(source)) {\n throw new Error('AgentCore returned an unsupported stream type.');\n }\n const iterator = source[Symbol.asyncIterator]();\n return new ReadableStream<Uint8Array>({\n async pull(controller) {\n try {\n const item = await iterator.next();\n if (item.done) {\n controller.close();\n return;\n }\n if (!(item.value instanceof Uint8Array)) {\n throw new Error('AgentCore returned a non-binary stream chunk.');\n }\n controller.enqueue(item.value);\n } catch (error) {\n controller.error(error);\n }\n },\n async cancel() {\n await iterator.return?.();\n },\n });\n}\n\nfunction isAsyncIterable(\n value: unknown,\n): value is AsyncIterable<Uint8Array> {\n return Boolean(\n value\n && typeof value === 'object'\n && Symbol.asyncIterator in value\n && typeof value[Symbol.asyncIterator] === 'function',\n );\n}\n\nfunction readServiceStatus(error: unknown): number | undefined {\n if (!error || typeof error !== 'object' || !('$metadata' in error)) {\n return undefined;\n }\n const metadata = (error as { $metadata?: { httpStatusCode?: unknown } })\n .$metadata;\n const status = metadata?.httpStatusCode;\n return typeof status === 'number' && status >= 400 && status <= 599\n ? status\n : undefined;\n}\n\nfunction readErrorName(error: unknown): string {\n return error instanceof Error ? error.name : '';\n}\n\nexport const AGENTCORE_FORWARDED_HEADER_NAMES = Object.freeze([\n EXECUTION_ASSERTION_HEADER,\n MCP_CAPABILITY_HEADER,\n MODEL_API_KEY_HEADER,\n] as const);\n\nexport const AGENTCORE_EXCLUDED_HEADER_NAMES = Object.freeze([\n EXECUTION_HOST_LOCAL_TOKEN_HEADER,\n] as const);\n"]}
|
|
1
|
+
{"version":3,"file":"agentcore-execution-host.js","sourceRoot":"","sources":["../../src/agentcore/agentcore-execution-host.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,sBAAsB,EACtB,yBAAyB,GAE1B,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AACpD,OAAO,EACL,gCAAgC,EAChC,0BAA0B,EAC1B,iCAAiC,EACjC,qBAAqB,EACrB,uBAAuB,GAGxB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,uBAAuB,GAKxB,MAAM,sBAAsB,CAAC;AAK9B,OAAO,EAAE,8BAA8B,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,YAAY,GAAG,kBAAkB,CAAC;AACxC,MAAM,MAAM,GAAG,mBAAmB,CAAC;AACnC,MAAM,6BAA6B,GAAG,EAAE,CAAC;AACzC,MAAM,6BAA6B,GAAG,GAAG,CAAC;AAC1C,MAAM,0BAA0B,GAAG,iCAAiC,CAAC;AACrE,MA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CAAC,KAAc;IACvC,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,CAAC,WAAW,IAAI,KAAK,CAAC,EAAE,CAAC;QACnE,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,MAAM,QAAQ,GAAI,KAAsD;SACrE,SAAS,CAAC;IACb,MAAM,MAAM,GAAG,QAAQ,EAAE,cAAc,CAAC;IACxC,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,MAAM,IAAI,GAAG,IAAI,MAAM,IAAI,GAAG;QACjE,CAAC,CAAC,MAAM;QACR,CAAC,CAAC,SAAS,CAAC;AAChB,CAAC;AAED,SAAS,aAAa,CAAC,KAAc;IACnC,OAAO,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC;AAClD,CAAC;AAED,MAAM,CAAC,MAAM,gCAAgC,GAAG,MAAM,CAAC,MAAM,CAAC;IAC5D,0BAA0B;IAC1B,qBAAqB;IACrB,uBAAuB;CACf,CAAC,CAAC;AAEZ,MAAM,CAAC,MAAM,+BAA+B,GAAG,MAAM,CAAC,MAAM,CAAC;IAC3D,iCAAiC;CACzB,CAAC,CAAC","sourcesContent":["import {\n BedrockAgentCoreClient,\n InvokeAgentRuntimeCommand,\n type InvokeAgentRuntimeCommandOutput,\n} from '@aws-sdk/client-bedrock-agentcore';\nimport { HttpRequest } from '@smithy/protocol-http';\nimport {\n AGENTCORE_RUNTIME_SESSION_HEADER,\n EXECUTION_ASSERTION_HEADER,\n EXECUTION_HOST_LOCAL_TOKEN_HEADER,\n MCP_CAPABILITY_HEADER,\n MODEL_CREDENTIAL_HEADER,\n type ExecutionHostHeartbeatStreamEvent,\n type ExecutionHostStreamEvent,\n} from '../contracts/index.js';\nimport {\n DirectHttpExecutionHost,\n type ExecutionHost,\n type ExecutionHostConversationTurn,\n type ExecutionHostHeartbeatTask,\n type HeartbeatExecutionHost,\n} from '../http-sse/index.js';\nimport type {\n AgentCoreExecutionHostConfig,\n AgentCoreRuntimeClient,\n} from './types.js';\nimport { AgentCoreExecutionTargetSchema } from './schemas.js';\n\nconst CONTENT_TYPE = 'application/json';\nconst ACCEPT = 'text/event-stream';\nconst MIN_RUNTIME_SESSION_ID_LENGTH = 33;\nconst MAX_RUNTIME_SESSION_ID_LENGTH = 256;\nconst RUNTIME_SESSION_ID_PATTERN = /^[A-Za-z0-9](?:-*[A-Za-z0-9])+$/;\nconst WIRE_BRIDGE_URL = new URL('http://127.0.0.1/agentcore-bridge');\nconst NON_FORWARDED_LOCAL_TOKEN = 'agentcore-bridge-token-never-forwarded';\nconst SERVICE_ERROR_CODES = new Map<string, string>([\n ['AccessDeniedException', 'access_denied'],\n ['InternalServerException', 'runtime_internal'],\n ['ResourceNotFoundException', 'runtime_not_found'],\n ['RetryableConflictException', 'runtime_conflict'],\n ['RuntimeClientError', 'runtime_client_error'],\n ['ServiceQuotaExceededException', 'quota_exceeded'],\n ['ThrottlingException', 'throttled'],\n ['ValidationException', 'invalid_request'],\n]);\n\n/**\n * Invokes one compatible Heddle Execution Host through AWS AgentCore while\n * reusing the package's strict request and SSE protocol validation.\n */\nexport class AgentCoreExecutionHost\nimplements ExecutionHost, HeartbeatExecutionHost {\n readonly #client: AgentCoreRuntimeClient;\n readonly #runtimeArn: string;\n readonly #qualifier?: string;\n readonly #wire: DirectHttpExecutionHost;\n\n constructor(config: AgentCoreExecutionHostConfig) {\n const { client, ...rawTarget } = config;\n const target = AgentCoreExecutionTargetSchema.parse(rawTarget);\n this.#runtimeArn = target.runtimeArn;\n this.#qualifier = target.qualifier;\n this.#client = client ?? new BedrockAgentCoreClient({\n region: target.region,\n // Invocation settlement is ambiguous after a transport interruption.\n // Product policy, not the AWS client, decides whether a turn may retry.\n maxAttempts: 1,\n });\n this.#wire = new DirectHttpExecutionHost({\n baseUrl: WIRE_BRIDGE_URL,\n localToken: NON_FORWARDED_LOCAL_TOKEN,\n fetch: (_input, init) => this.#invoke(init),\n });\n }\n\n streamConversationTurn(\n input: ExecutionHostConversationTurn,\n ): AsyncIterable<ExecutionHostStreamEvent> {\n assertAgentCoreRuntimeSessionId(input.runtimeSessionId);\n return this.#wire.streamConversationTurn(input);\n }\n\n streamHeartbeatTask(\n input: ExecutionHostHeartbeatTask,\n ): AsyncIterable<ExecutionHostHeartbeatStreamEvent> {\n assertAgentCoreRuntimeSessionId(input.runtimeSessionId);\n return this.#wire.streamHeartbeatTask(input);\n }\n\n close(): void {\n this.#client.destroy?.();\n }\n\n async #invoke(init?: RequestInit): Promise<Response> {\n if (init?.method !== 'POST' || typeof init.body !== 'string') {\n throw new Error('AgentCore wire bridge received an invalid request.');\n }\n const headers = new Headers(init.headers);\n const runtimeSessionId = requireHeader(\n headers,\n AGENTCORE_RUNTIME_SESSION_HEADER,\n );\n const customHeaders = Object.fromEntries([\n [\n EXECUTION_ASSERTION_HEADER,\n requireHeader(headers, EXECUTION_ASSERTION_HEADER),\n ],\n [\n MODEL_CREDENTIAL_HEADER,\n requireHeader(headers, MODEL_CREDENTIAL_HEADER),\n ],\n ...(headers.has(MCP_CAPABILITY_HEADER)\n ? [[MCP_CAPABILITY_HEADER, headers.get(MCP_CAPABILITY_HEADER)!]]\n : []),\n ]);\n const command = new InvokeAgentRuntimeCommand({\n agentRuntimeArn: this.#runtimeArn,\n runtimeSessionId,\n qualifier: this.#qualifier,\n contentType: CONTENT_TYPE,\n accept: ACCEPT,\n payload: new TextEncoder().encode(init.body),\n });\n addSignedCustomHeaders(command, customHeaders);\n const signal = init.signal ?? undefined;\n\n try {\n const output = await this.#client.send(command, { abortSignal: signal });\n return new Response(\n output.response ? toReadableStream(output.response) : null,\n {\n status: output.statusCode ?? output.$metadata.httpStatusCode ?? 200,\n headers: {\n 'content-type': output.contentType ?? 'application/octet-stream',\n },\n },\n );\n } catch (error) {\n if (signal?.aborted) {\n throw error;\n }\n const status = readServiceStatus(error);\n if (!status) {\n throw error;\n }\n const code = SERVICE_ERROR_CODES.get(readErrorName(error)) ?? 'unknown';\n return new Response(JSON.stringify({\n error: {\n code,\n message: 'AgentCore rejected the invocation.',\n },\n }), {\n status,\n headers: { 'content-type': CONTENT_TYPE },\n });\n }\n }\n}\n\nfunction assertAgentCoreRuntimeSessionId(value: string): void {\n if (\n value.length < MIN_RUNTIME_SESSION_ID_LENGTH\n || value.length > MAX_RUNTIME_SESSION_ID_LENGTH\n || !RUNTIME_SESSION_ID_PATTERN.test(value)\n ) {\n throw new Error('AgentCore runtime session ID is not provider-compatible.');\n }\n}\n\nfunction addSignedCustomHeaders(\n command: InvokeAgentRuntimeCommand,\n headers: Readonly<Record<string, string>>,\n): void {\n command.middlewareStack.add(\n (next) => async (args) => {\n if (!HttpRequest.isInstance(args.request)) {\n throw new Error('AgentCore invocation did not produce an HTTP request.');\n }\n Object.assign(args.request.headers, headers);\n return await next(args);\n },\n {\n step: 'build',\n priority: 'low',\n name: 'heddleAgentCoreCustomHeaders',\n },\n );\n}\n\nfunction requireHeader(headers: Headers, name: string): string {\n const value = headers.get(name);\n if (!value) {\n throw new Error('AgentCore wire bridge omitted required authority.');\n }\n return value;\n}\n\nfunction toReadableStream(\n source: NonNullable<InvokeAgentRuntimeCommandOutput['response']>,\n): ReadableStream<Uint8Array> {\n if (source instanceof Blob) {\n return source.stream();\n }\n if (source instanceof ReadableStream) {\n return source;\n }\n if (!isAsyncIterable(source)) {\n throw new Error('AgentCore returned an unsupported stream type.');\n }\n const iterator = source[Symbol.asyncIterator]();\n return new ReadableStream<Uint8Array>({\n async pull(controller) {\n try {\n const item = await iterator.next();\n if (item.done) {\n controller.close();\n return;\n }\n if (!(item.value instanceof Uint8Array)) {\n throw new Error('AgentCore returned a non-binary stream chunk.');\n }\n controller.enqueue(item.value);\n } catch (error) {\n controller.error(error);\n }\n },\n async cancel() {\n await iterator.return?.();\n },\n });\n}\n\nfunction isAsyncIterable(\n value: unknown,\n): value is AsyncIterable<Uint8Array> {\n return Boolean(\n value\n && typeof value === 'object'\n && Symbol.asyncIterator in value\n && typeof value[Symbol.asyncIterator] === 'function',\n );\n}\n\nfunction readServiceStatus(error: unknown): number | undefined {\n if (!error || typeof error !== 'object' || !('$metadata' in error)) {\n return undefined;\n }\n const metadata = (error as { $metadata?: { httpStatusCode?: unknown } })\n .$metadata;\n const status = metadata?.httpStatusCode;\n return typeof status === 'number' && status >= 400 && status <= 599\n ? status\n : undefined;\n}\n\nfunction readErrorName(error: unknown): string {\n return error instanceof Error ? error.name : '';\n}\n\nexport const AGENTCORE_FORWARDED_HEADER_NAMES = Object.freeze([\n EXECUTION_ASSERTION_HEADER,\n MCP_CAPABILITY_HEADER,\n MODEL_CREDENTIAL_HEADER,\n] as const);\n\nexport const AGENTCORE_EXCLUDED_HEADER_NAMES = Object.freeze([\n EXECUTION_HOST_LOCAL_TOKEN_HEADER,\n] as const);\n"]}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
export type HostctlIo = {
|
|
3
|
+
stdout: {
|
|
4
|
+
write(value: string): unknown;
|
|
5
|
+
};
|
|
6
|
+
stderr: {
|
|
7
|
+
write(value: string): unknown;
|
|
8
|
+
};
|
|
9
|
+
};
|
|
10
|
+
export declare function runHostctl(args: readonly string[], io?: HostctlIo): Promise<number>;
|
|
11
|
+
//# sourceMappingURL=hostctl.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostctl.d.ts","sourceRoot":"","sources":["../../src/cli/hostctl.ts"],"names":[],"mappings":";AAMA,MAAM,MAAM,SAAS,GAAG;IACtB,MAAM,EAAE;QAAE,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;IAC1C,MAAM,EAAE;QAAE,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CAC3C,CAAC;AAEF,wBAAsB,UAAU,CAC9B,IAAI,EAAE,SAAS,MAAM,EAAE,EACvB,EAAE,GAAE,SAAmB,GACtB,OAAO,CAAC,MAAM,CAAC,CAajB"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
import { resolve } from 'node:path';
|
|
3
|
+
import { fileURLToPath } from 'node:url';
|
|
4
|
+
import { Command, CommanderError } from 'commander';
|
|
5
|
+
import { initializeLocalCredentialBundle } from '../node/local-credential-bundle.js';
|
|
6
|
+
export async function runHostctl(args, io = process) {
|
|
7
|
+
const program = createHostctl(io);
|
|
8
|
+
try {
|
|
9
|
+
await program.parseAsync([...args], { from: 'user' });
|
|
10
|
+
return 0;
|
|
11
|
+
}
|
|
12
|
+
catch (error) {
|
|
13
|
+
if (error instanceof CommanderError) {
|
|
14
|
+
return error.exitCode;
|
|
15
|
+
}
|
|
16
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
17
|
+
io.stderr.write(`heddle-hostctl: ${message}\n`);
|
|
18
|
+
return 1;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
function createHostctl(io) {
|
|
22
|
+
const program = new Command()
|
|
23
|
+
.name('heddle-hostctl')
|
|
24
|
+
.description('Operate a self-hosted Heddle Execution Host.')
|
|
25
|
+
.configureOutput({
|
|
26
|
+
writeOut: (value) => { io.stdout.write(value); },
|
|
27
|
+
writeErr: (value) => { io.stderr.write(value); },
|
|
28
|
+
})
|
|
29
|
+
.exitOverride()
|
|
30
|
+
.showHelpAfterError()
|
|
31
|
+
.allowExcessArguments(false);
|
|
32
|
+
program.command('credentials')
|
|
33
|
+
.description('Manage generic local host credentials.')
|
|
34
|
+
.command('init')
|
|
35
|
+
.description('Create or validate an owner-only credential bundle.')
|
|
36
|
+
.requiredOption('-o, --output <directory>', 'credential bundle directory')
|
|
37
|
+
.action(async ({ output }) => {
|
|
38
|
+
const initialized = await initializeLocalCredentialBundle(output);
|
|
39
|
+
io.stdout.write(`${initialized.created ? 'Initialized' : 'Validated'} Heddle local hosted credentials.\n`);
|
|
40
|
+
io.stdout.write(`Directory: ${initialized.paths.directory}\n`);
|
|
41
|
+
io.stdout.write(`Manifest: ${initialized.paths.manifest}\n`);
|
|
42
|
+
});
|
|
43
|
+
return program;
|
|
44
|
+
}
|
|
45
|
+
if (process.argv[1]
|
|
46
|
+
&& resolve(process.argv[1]) === fileURLToPath(import.meta.url)) {
|
|
47
|
+
process.exitCode = await runHostctl(process.argv.slice(2));
|
|
48
|
+
}
|
|
49
|
+
//# sourceMappingURL=hostctl.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"hostctl.js","sourceRoot":"","sources":["../../src/cli/hostctl.ts"],"names":[],"mappings":";AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EAAE,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,+BAA+B,EAAE,MAAM,oCAAoC,CAAC;AAOrF,MAAM,CAAC,KAAK,UAAU,UAAU,CAC9B,IAAuB,EACvB,KAAgB,OAAO;IAEvB,MAAM,OAAO,GAAG,aAAa,CAAC,EAAE,CAAC,CAAC;IAClC,IAAI,CAAC;QACH,MAAM,OAAO,CAAC,UAAU,CAAC,CAAC,GAAG,IAAI,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QACtD,OAAO,CAAC,CAAC;IACX,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,IAAI,KAAK,YAAY,cAAc,EAAE,CAAC;YACpC,OAAO,KAAK,CAAC,QAAQ,CAAC;QACxB,CAAC;QACD,MAAM,OAAO,GAAG,KAAK,YAAY,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACvE,EAAE,CAAC,MAAM,CAAC,KAAK,CAAC,mBAAmB,OAAO,IAAI,CAAC,CAAC;QAChD,OAAO,CAAC,CAAC;IACX,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AC;OACZ,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,KAAK,aAAa,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAC9D,CAAC;IACD,OAAO,CAAC,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC7D,CAAC","sourcesContent":["#!/usr/bin/env node\nimport { resolve } from 'node:path';\nimport { fileURLToPath } from 'node:url';\nimport { Command, CommanderError } from 'commander';\nimport { initializeLocalCredentialBundle } from '../node/local-credential-bundle.js';\n\nexport type HostctlIo = {\n stdout: { write(value: string): unknown };\n stderr: { write(value: string): unknown };\n};\n\nexport async function runHostctl(\n args: readonly string[],\n io: HostctlIo = process,\n): Promise<number> {\n const program = createHostctl(io);\n try {\n await program.parseAsync([...args], { from: 'user' });\n return 0;\n } catch (error) {\n if (error instanceof CommanderError) {\n return error.exitCode;\n }\n const message = error instanceof Error ? error.message : String(error);\n io.stderr.write(`heddle-hostctl: ${message}\\n`);\n return 1;\n }\n}\n\nfunction createHostctl(io: HostctlIo): Command {\n const program = new Command()\n .name('heddle-hostctl')\n .description('Operate a self-hosted Heddle Execution Host.')\n .configureOutput({\n writeOut: (value) => { io.stdout.write(value); },\n writeErr: (value) => { io.stderr.write(value); },\n })\n .exitOverride()\n .showHelpAfterError()\n .allowExcessArguments(false);\n\n program.command('credentials')\n .description('Manage generic local host credentials.')\n .command('init')\n .description('Create or validate an owner-only credential bundle.')\n .requiredOption('-o, --output <directory>', 'credential bundle directory')\n .action(async ({ output }: { output: string }) => {\n const initialized = await initializeLocalCredentialBundle(output);\n io.stdout.write(\n `${initialized.created ? 'Initialized' : 'Validated'} Heddle local hosted credentials.\\n`,\n );\n io.stdout.write(`Directory: ${initialized.paths.directory}\\n`);\n io.stdout.write(`Manifest: ${initialized.paths.manifest}\\n`);\n });\n\n return program;\n}\n\nif (\n process.argv[1]\n && resolve(process.argv[1]) === fileURLToPath(import.meta.url)\n) {\n process.exitCode = await runHostctl(process.argv.slice(2));\n}\n"]}
|
|
@@ -8,12 +8,26 @@ export declare const AGENTCORE_RUNTIME_SESSION_HEADER: "x-amzn-bedrock-agentcore
|
|
|
8
8
|
export declare const EXECUTION_HOST_LOCAL_TOKEN_HEADER: "x-heddle-execution-host-local-token";
|
|
9
9
|
export declare const EXECUTION_ASSERTION_HEADER: "x-heddle-execution-host-assertion";
|
|
10
10
|
export declare const MCP_CAPABILITY_HEADER: "x-heddle-execution-host-mcp-capability";
|
|
11
|
-
export declare const
|
|
11
|
+
export declare const MODEL_CREDENTIAL_HEADER: "x-heddle-execution-host-model-credential";
|
|
12
12
|
export declare const OpaqueIdSchema: z.ZodString;
|
|
13
13
|
export declare const JwtIssuerSchema: z.ZodURL;
|
|
14
14
|
export declare const JwtAudienceSchema: z.ZodString;
|
|
15
15
|
export declare const RuntimeSessionIdSchema: z.ZodString;
|
|
16
16
|
export declare const TimestampSchema: z.ZodISODateTime;
|
|
17
|
+
/**
|
|
18
|
+
* One invocation-scoped model credential. OAuth refresh material is
|
|
19
|
+
* deliberately absent from the wire contract.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ExecutionHostModelCredentialSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
|
|
22
|
+
type: z.ZodLiteral<"api-key">;
|
|
23
|
+
apiKey: z.ZodString;
|
|
24
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
25
|
+
type: z.ZodLiteral<"oauth-access-token">;
|
|
26
|
+
provider: z.ZodLiteral<"openai">;
|
|
27
|
+
accessToken: z.ZodString;
|
|
28
|
+
expiresAt: z.ZodNumber;
|
|
29
|
+
accountId: z.ZodOptional<z.ZodString>;
|
|
30
|
+
}, z.core.$strict>], "type">;
|
|
17
31
|
export declare const McpServerIdSchema: z.ZodString;
|
|
18
32
|
export declare const McpToolNameSchema: z.ZodString;
|
|
19
33
|
export declare const McpAllowedToolsSchema: z.ZodArray<z.ZodString>;
|
|
@@ -246,6 +260,7 @@ export declare const McpCapabilityClaimsSchema: z.ZodObject<{
|
|
|
246
260
|
exp: z.ZodNumber;
|
|
247
261
|
}, z.core.$loose>;
|
|
248
262
|
export type ExecutionScope = z.infer<typeof ExecutionScopeSchema>;
|
|
263
|
+
export type ExecutionHostModelCredential = z.infer<typeof ExecutionHostModelCredentialSchema>;
|
|
249
264
|
export type ExecutionHostConversationTurnRequest = z.infer<typeof ExecutionHostConversationTurnRequestSchema>;
|
|
250
265
|
export type ExecutionHostHeartbeatTaskRequest = z.infer<typeof ExecutionHostHeartbeatTaskRequestSchema>;
|
|
251
266
|
export type RuntimePublicResult = z.infer<typeof RuntimePublicResultSchema>;
|
|
@@ -263,4 +278,6 @@ export type HostedExecutionWorkflow = z.infer<typeof HostedExecutionWorkflowSche
|
|
|
263
278
|
export declare function isExecutionHostTerminalEvent(event: ExecutionHostStreamEvent): event is ExecutionHostTerminalEvent;
|
|
264
279
|
export declare function isExecutionHostHeartbeatTerminalEvent(event: ExecutionHostHeartbeatStreamEvent): event is ExecutionHostHeartbeatTerminalEvent;
|
|
265
280
|
export declare function isSafeWebUrl(url: URL): boolean;
|
|
281
|
+
/** Explicit Docker Desktop bridge exception for isolated local composition. */
|
|
282
|
+
export declare function isDockerLocalWebUrl(url: URL): boolean;
|
|
266
283
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,eAAO,MAAM,0BAA0B,EAAG,CAAU,CAAC;AACrD,eAAO,MAAM,0BAA0B,EAAG,mBAA4B,CAAC;AACvE,eAAO,MAAM,uBAAuB,EAAG,gBAAyB,CAAC;AACjE,eAAO,MAAM,wBAAwB,EAAG,sBAA+B,CAAC;AACxE,eAAO,MAAM,mBAAmB,EAAG,2BAAoC,CAAC;AAExE,e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AAA;CAAE,CAC3C,CAAC;AACF,MAAM,MAAM,iCAAiC,GAAG,CAAC,CAAC,KAAK,CACrD,OAAO,uCAAuC,CAC/C,CAAC;AACF,MAAM,MAAM,mCAAmC,GAAG,OAAO,CACvD,iCAAiC,EACjC;IAAE,IAAI,EAAE,QAAQ,GAAG,WAAW,GAAG,OAAO,CAAA;CAAE,CAC3C,CAAC;AACF,MAAM,MAAM,wBAAwB,GAAG,CAAC,CAAC,KAAK,CAC5C,OAAO,8BAA8B,CACtC,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,yBAAyB,CAAC,CAAC;AAC5E,MAAM,MAAM,uBAAuB,GAAG,CAAC,CAAC,KAAK,CAC3C,OAAO,6BAA6B,CACrC,CAAC;AAEF,wBAAgB,4BAA4B,CAC1C,KAAK,EAAE,wBAAwB,GAC9B,KAAK,IAAI,0BAA0B,CAIrC;AAED,wBAAgB,qCAAqC,CACnD,KAAK,EAAE,iCAAiC,GACvC,KAAK,IAAI,mCAAmC,CAI9C;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAO9C;AAED,+EAA+E;AAC/E,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,GAAG,GAAG,OAAO,CAOrD"}
|
package/dist/contracts/index.js
CHANGED
|
@@ -8,7 +8,7 @@ export const AGENTCORE_RUNTIME_SESSION_HEADER = 'x-amzn-bedrock-agentcore-runtim
|
|
|
8
8
|
export const EXECUTION_HOST_LOCAL_TOKEN_HEADER = 'x-heddle-execution-host-local-token';
|
|
9
9
|
export const EXECUTION_ASSERTION_HEADER = 'x-heddle-execution-host-assertion';
|
|
10
10
|
export const MCP_CAPABILITY_HEADER = 'x-heddle-execution-host-mcp-capability';
|
|
11
|
-
export const
|
|
11
|
+
export const MODEL_CREDENTIAL_HEADER = 'x-heddle-execution-host-model-credential';
|
|
12
12
|
export const OpaqueIdSchema = z
|
|
13
13
|
.string()
|
|
14
14
|
.min(1)
|
|
@@ -22,6 +22,24 @@ export const RuntimeSessionIdSchema = z
|
|
|
22
22
|
.max(256)
|
|
23
23
|
.refine((value) => value === value.trim(), 'must not contain outer whitespace');
|
|
24
24
|
export const TimestampSchema = z.iso.datetime({ offset: true });
|
|
25
|
+
const ModelSecretSchema = z.string().trim().min(8).max(4_096);
|
|
26
|
+
/**
|
|
27
|
+
* One invocation-scoped model credential. OAuth refresh material is
|
|
28
|
+
* deliberately absent from the wire contract.
|
|
29
|
+
*/
|
|
30
|
+
export const ExecutionHostModelCredentialSchema = z.discriminatedUnion('type', [
|
|
31
|
+
z.object({
|
|
32
|
+
type: z.literal('api-key'),
|
|
33
|
+
apiKey: ModelSecretSchema,
|
|
34
|
+
}).strict(),
|
|
35
|
+
z.object({
|
|
36
|
+
type: z.literal('oauth-access-token'),
|
|
37
|
+
provider: z.literal('openai'),
|
|
38
|
+
accessToken: ModelSecretSchema,
|
|
39
|
+
expiresAt: z.number().int().positive(),
|
|
40
|
+
accountId: z.string().trim().min(1).max(512).optional(),
|
|
41
|
+
}).strict(),
|
|
42
|
+
]);
|
|
25
43
|
export const McpServerIdSchema = z
|
|
26
44
|
.string()
|
|
27
45
|
.min(1)
|
|
@@ -211,4 +229,13 @@ export function isSafeWebUrl(url) {
|
|
|
211
229
|
&& !url.search
|
|
212
230
|
&& !url.hash;
|
|
213
231
|
}
|
|
232
|
+
/** Explicit Docker Desktop bridge exception for isolated local composition. */
|
|
233
|
+
export function isDockerLocalWebUrl(url) {
|
|
234
|
+
return url.protocol === 'http:'
|
|
235
|
+
&& url.hostname === 'host.docker.internal'
|
|
236
|
+
&& !url.username
|
|
237
|
+
&& !url.password
|
|
238
|
+
&& !url.search
|
|
239
|
+
&& !url.hash;
|
|
240
|
+
}
|
|
214
241
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,OA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MAAM;WACX,CAAC,GAAG,CAAC,IAAI,CAAC;AACjB,CAAC","sourcesContent":["import { z } from 'zod';\n\nexport const EXECUTION_CONTRACT_VERSION = 1 as const;\nexport const CONVERSATION_TURN_WORKFLOW = 'conversation-turn' as const;\nexport const HEARTBEAT_TASK_WORKFLOW = 'heartbeat-task' as const;\nexport const EXECUTION_ASSERTION_TYPE = 'heddle-execution+jwt' as const;\nexport const MCP_CAPABILITY_TYPE = 'heddle-mcp-capability+jwt' as const;\n\nexport const AGENTCORE_RUNTIME_SESSION_HEADER =\n 'x-amzn-bedrock-agentcore-runtime-session-id' as const;\nexport const EXECUTION_HOST_LOCAL_TOKEN_HEADER =\n 'x-heddle-execution-host-local-token' as const;\nexport const EXECUTION_ASSERTION_HEADER =\n 'x-heddle-execution-host-assertion' as const;\nexport const MCP_CAPABILITY_HEADER =\n 'x-heddle-execution-host-mcp-capability' as const;\nexport const MODEL_API_KEY_HEADER =\n 'x-heddle-execution-host-model-api-key' as const;\n\nexport const OpaqueIdSchema = z\n .string()\n .min(1)\n .max(128)\n .regex(\n /^[A-Za-z0-9][A-Za-z0-9._:@-]*$/,\n 'must be an opaque, path-free identifier',\n );\n\nexport const JwtIssuerSchema = z.url().refine(\n (value) => isSafeWebUrl(new URL(value)),\n 'must use HTTPS or loopback HTTP and contain no credentials, query, or fragment',\n);\n\nexport const JwtAudienceSchema = z.string().min(1).max(512);\n\nexport const RuntimeSessionIdSchema = z\n .string()\n .min(33)\n .max(256)\n .refine((value) => value === value.trim(), 'must not contain outer whitespace');\n\nexport const TimestampSchema = z.iso.datetime({ offset: true });\n\nexport const McpServerIdSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(\n /^[A-Za-z0-9_-]+$/,\n 'must be a Heddle-compatible MCP server identifier',\n );\n\nexport const McpToolNameSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(\n /^[A-Za-z][A-Za-z0-9_]*$/,\n 'must be a collision-free MCP tool name',\n );\n\nexport const McpAllowedToolsSchema = z\n .array(McpToolNameSchema)\n .min(1)\n .max(16)\n .refine((tools) => new Set(tools).size === tools.length, {\n message: 'must contain unique MCP tool names',\n })\n .refine(\n (tools) => tools.reduce(\n (characterCount, toolName) => characterCount + toolName.length,\n 0,\n ) <= 512,\n { message: 'contains too many aggregate tool-name characters' },\n );\n\nexport const ExecutionScopeSchema = z.object({\n adopterId: OpaqueIdSchema,\n tenantId: OpaqueIdSchema,\n subjectId: OpaqueIdSchema,\n productSessionId: OpaqueIdSchema,\n}).strict();\n\nexport const ExecutionHostConversationTurnRequestSchema = z.object({\n schemaVersion: z.literal(EXECUTION_CONTRACT_VERSION),\n kind: z.literal(CONVERSATION_TURN_WORKFLOW),\n invocationId: OpaqueIdSchema,\n prompt: z.string().trim().min(1).max(200_000),\n deadlineAt: TimestampSchema.optional(),\n}).strict();\n\nexport const HeartbeatRunContextSchema = z.object({\n currentDateTime: TimestampSchema,\n intervalMs: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),\n continuationMode: z.enum(['operator', 'agent']).optional(),\n nextRunAt: TimestampSchema.optional(),\n previousRunAt: TimestampSchema.optional(),\n previousRunId: OpaqueIdSchema.optional(),\n}).strict();\n\nexport const ExecutionHostHeartbeatTaskRequestSchema = z.object({\n schemaVersion: z.literal(EXECUTION_CONTRACT_VERSION),\n kind: z.literal(HEARTBEAT_TASK_WORKFLOW),\n invocationId: OpaqueIdSchema,\n taskId: OpaqueIdSchema,\n task: z.string().trim().min(1).max(200_000),\n checkpoint: z.record(z.string(), z.json()).optional(),\n runContext: HeartbeatRunContextSchema,\n model: z.string().trim().min(1).max(512).optional(),\n reasoningEffort: z.enum([\n 'none',\n 'low',\n 'medium',\n 'high',\n 'ultrahigh',\n 'max',\n ]).optional(),\n maxSteps: z.number().int().positive().max(10_000).optional(),\n searchIgnoreDirs: z.array(z.string().min(1).max(1_024)).max(1_000).optional(),\n systemContext: z.string().max(200_000).optional(),\n deadlineAt: TimestampSchema.optional(),\n}).strict();\n\nexport const RuntimePublicResultSchema = z.object({\n outcome: z.enum(['done', 'max_steps', 'error', 'interrupted']),\n summary: z.string().optional(),\n failure: z.object({\n source: z.literal('model'),\n code: z.enum([\n 'authentication',\n 'permission',\n 'quota',\n 'rate_limit',\n 'context_window',\n 'request',\n 'transport',\n 'empty_response',\n 'unknown',\n ]),\n }).strict().optional(),\n}).strict();\n\nconst StreamEnvelopeSchema = z.object({\n schemaVersion: z.literal(EXECUTION_CONTRACT_VERSION),\n invocationId: OpaqueIdSchema,\n runId: OpaqueIdSchema,\n sequence: z.number().int().nonnegative(),\n timestamp: TimestampSchema,\n});\n\nexport const ExecutionHostStreamEventSchema = z.discriminatedUnion('kind', [\n StreamEnvelopeSchema.extend({\n sequence: z.literal(0),\n kind: z.literal('accepted'),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('activity'),\n activity: z.unknown(),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('result'),\n result: RuntimePublicResultSchema,\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('cancelled'),\n reason: z.string(),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('error'),\n error: z.object({\n code: z.string().min(1).max(128).regex(/^[a-z0-9_]+$/),\n message: z.string().min(1).max(1_600),\n }).strict(),\n }).strict(),\n]);\n\nexport const ExecutionHostHeartbeatStreamEventSchema = z.discriminatedUnion(\n 'kind',\n [\n StreamEnvelopeSchema.extend({\n sequence: z.literal(0),\n kind: z.literal('accepted'),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('activity'),\n activity: z.json(),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('result'),\n result: z.record(z.string(), z.json()),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('cancelled'),\n reason: z.string(),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('error'),\n error: z.object({\n code: z.string().min(1).max(128).regex(/^[a-z0-9_]+$/),\n message: z.string().min(1).max(1_600),\n }).strict(),\n }).strict(),\n ],\n);\n\nexport const HostedExecutionWorkflowSchema = z.enum([\n CONVERSATION_TURN_WORKFLOW,\n HEARTBEAT_TASK_WORKFLOW,\n]);\n\nexport const ExecutionAssertionClaimsSchema = z.object({\n iss: JwtIssuerSchema,\n aud: JwtAudienceSchema,\n contractVersion: z.literal(EXECUTION_CONTRACT_VERSION),\n adopterId: OpaqueIdSchema,\n tenantId: OpaqueIdSchema,\n productSessionId: OpaqueIdSchema,\n runtimeSessionId: RuntimeSessionIdSchema,\n workflow: HostedExecutionWorkflowSchema,\n sub: OpaqueIdSchema,\n jti: OpaqueIdSchema,\n iat: z.number().int().nonnegative(),\n exp: z.number().int().positive(),\n}).passthrough();\n\nexport const McpCapabilityClaimsSchema = z.object({\n iss: JwtIssuerSchema,\n aud: JwtAudienceSchema,\n contractVersion: z.literal(EXECUTION_CONTRACT_VERSION),\n adopterId: OpaqueIdSchema,\n tenantId: OpaqueIdSchema,\n productSessionId: OpaqueIdSchema,\n runtimeSessionId: RuntimeSessionIdSchema,\n invocationId: OpaqueIdSchema,\n workflow: HostedExecutionWorkflowSchema,\n serverId: McpServerIdSchema,\n allowedTools: McpAllowedToolsSchema,\n sub: OpaqueIdSchema,\n jti: OpaqueIdSchema,\n iat: z.number().int().nonnegative(),\n exp: z.number().int().positive(),\n}).passthrough();\n\nexport type ExecutionScope = z.infer<typeof ExecutionScopeSchema>;\nexport type ExecutionHostConversationTurnRequest = z.infer<\n typeof ExecutionHostConversationTurnRequestSchema\n>;\nexport type ExecutionHostHeartbeatTaskRequest = z.infer<\n typeof ExecutionHostHeartbeatTaskRequestSchema\n>;\nexport type RuntimePublicResult = z.infer<typeof RuntimePublicResultSchema>;\nexport type ExecutionHostStreamEvent = z.infer<\n typeof ExecutionHostStreamEventSchema\n>;\nexport type ExecutionHostTerminalEvent = Extract<\n ExecutionHostStreamEvent,\n { kind: 'result' | 'cancelled' | 'error' }\n>;\nexport type ExecutionHostHeartbeatStreamEvent = z.infer<\n typeof ExecutionHostHeartbeatStreamEventSchema\n>;\nexport type ExecutionHostHeartbeatTerminalEvent = Extract<\n ExecutionHostHeartbeatStreamEvent,\n { kind: 'result' | 'cancelled' | 'error' }\n>;\nexport type ExecutionAssertionClaims = z.infer<\n typeof ExecutionAssertionClaimsSchema\n>;\nexport type McpCapabilityClaims = z.infer<typeof McpCapabilityClaimsSchema>;\nexport type HostedExecutionWorkflow = z.infer<\n typeof HostedExecutionWorkflowSchema\n>;\n\nexport function isExecutionHostTerminalEvent(\n event: ExecutionHostStreamEvent,\n): event is ExecutionHostTerminalEvent {\n return event.kind === 'result'\n || event.kind === 'cancelled'\n || event.kind === 'error';\n}\n\nexport function isExecutionHostHeartbeatTerminalEvent(\n event: ExecutionHostHeartbeatStreamEvent,\n): event is ExecutionHostHeartbeatTerminalEvent {\n return event.kind === 'result'\n || event.kind === 'cancelled'\n || event.kind === 'error';\n}\n\nexport function isSafeWebUrl(url: URL): boolean {\n const loopback = ['127.0.0.1', '[::1]', 'localhost'].includes(url.hostname);\n return (url.protocol === 'https:' || (url.protocol === 'http:' && loopback))\n && !url.username\n && !url.password\n && !url.search\n && !url.hash;\n}\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/contracts/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAU,CAAC;AACrD,MAAM,CAAC,MAAM,0BAA0B,GAAG,mBAA4B,CAAC;AACvE,MAAM,CAAC,MAAM,uBAAuB,GAAG,gBAAyB,CAAC;AACjE,MAAM,CAAC,MAAM,wBAAwB,GAAG,sBAA+B,CAAC;AACxE,MAAM,CAAC,MAAM,mBAAmB,GAAG,2BAAoC,CAAC;AAExE,MAAM,CAAC,MAAM,gCAAgC,GAC3C,6CAAsD,CAAC;AACzD,MAAM,CAAC,MAAM,iCAAiC,GAC5C,qCAA8C,CAAC;AACjD,MAAM,C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AAC;AAC9B,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,GAAQ;IACnC,MAAM,QAAQ,GAAG,CAAC,WAAW,EAAE,OAAO,EAAE,WAAW,CAAC,CAAC,QAAQ,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAC5E,OAAO,CAAC,GAAG,CAAC,QAAQ,KAAK,QAAQ,IAAI,CAAC,GAAG,CAAC,QAAQ,KAAK,OAAO,IAAI,QAAQ,CAAC,CAAC;WACvE,CAAC,GAAG,CAAC,QAAQ;WACb,CAAC,GAAG,CAAC,QAAQ;WACb,CAAC,GAAG,CAAC,MAAM;WACX,CAAC,GAAG,CAAC,IAAI,CAAC;AACjB,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,mBAAmB,CAAC,GAAQ;IAC1C,OAAO,GAAG,CAAC,QAAQ,KAAK,OAAO;WAC1B,GAAG,CAAC,QAAQ,KAAK,sBAAsB;WACvC,CAAC,GAAG,CAAC,QAAQ;WACb,CAAC,GAAG,CAAC,QAAQ;WACb,CAAC,GAAG,CAAC,MAAM;WACX,CAAC,GAAG,CAAC,IAAI,CAAC;AACjB,CAAC","sourcesContent":["import { z } from 'zod';\n\nexport const EXECUTION_CONTRACT_VERSION = 1 as const;\nexport const CONVERSATION_TURN_WORKFLOW = 'conversation-turn' as const;\nexport const HEARTBEAT_TASK_WORKFLOW = 'heartbeat-task' as const;\nexport const EXECUTION_ASSERTION_TYPE = 'heddle-execution+jwt' as const;\nexport const MCP_CAPABILITY_TYPE = 'heddle-mcp-capability+jwt' as const;\n\nexport const AGENTCORE_RUNTIME_SESSION_HEADER =\n 'x-amzn-bedrock-agentcore-runtime-session-id' as const;\nexport const EXECUTION_HOST_LOCAL_TOKEN_HEADER =\n 'x-heddle-execution-host-local-token' as const;\nexport const EXECUTION_ASSERTION_HEADER =\n 'x-heddle-execution-host-assertion' as const;\nexport const MCP_CAPABILITY_HEADER =\n 'x-heddle-execution-host-mcp-capability' as const;\nexport const MODEL_CREDENTIAL_HEADER =\n 'x-heddle-execution-host-model-credential' as const;\n\nexport const OpaqueIdSchema = z\n .string()\n .min(1)\n .max(128)\n .regex(\n /^[A-Za-z0-9][A-Za-z0-9._:@-]*$/,\n 'must be an opaque, path-free identifier',\n );\n\nexport const JwtIssuerSchema = z.url().refine(\n (value) => isSafeWebUrl(new URL(value)),\n 'must use HTTPS or loopback HTTP and contain no credentials, query, or fragment',\n);\n\nexport const JwtAudienceSchema = z.string().min(1).max(512);\n\nexport const RuntimeSessionIdSchema = z\n .string()\n .min(33)\n .max(256)\n .refine((value) => value === value.trim(), 'must not contain outer whitespace');\n\nexport const TimestampSchema = z.iso.datetime({ offset: true });\n\nconst ModelSecretSchema = z.string().trim().min(8).max(4_096);\n\n/**\n * One invocation-scoped model credential. OAuth refresh material is\n * deliberately absent from the wire contract.\n */\nexport const ExecutionHostModelCredentialSchema = z.discriminatedUnion(\n 'type',\n [\n z.object({\n type: z.literal('api-key'),\n apiKey: ModelSecretSchema,\n }).strict(),\n z.object({\n type: z.literal('oauth-access-token'),\n provider: z.literal('openai'),\n accessToken: ModelSecretSchema,\n expiresAt: z.number().int().positive(),\n accountId: z.string().trim().min(1).max(512).optional(),\n }).strict(),\n ],\n);\n\nexport const McpServerIdSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(\n /^[A-Za-z0-9_-]+$/,\n 'must be a Heddle-compatible MCP server identifier',\n );\n\nexport const McpToolNameSchema = z\n .string()\n .min(1)\n .max(64)\n .regex(\n /^[A-Za-z][A-Za-z0-9_]*$/,\n 'must be a collision-free MCP tool name',\n );\n\nexport const McpAllowedToolsSchema = z\n .array(McpToolNameSchema)\n .min(1)\n .max(16)\n .refine((tools) => new Set(tools).size === tools.length, {\n message: 'must contain unique MCP tool names',\n })\n .refine(\n (tools) => tools.reduce(\n (characterCount, toolName) => characterCount + toolName.length,\n 0,\n ) <= 512,\n { message: 'contains too many aggregate tool-name characters' },\n );\n\nexport const ExecutionScopeSchema = z.object({\n adopterId: OpaqueIdSchema,\n tenantId: OpaqueIdSchema,\n subjectId: OpaqueIdSchema,\n productSessionId: OpaqueIdSchema,\n}).strict();\n\nexport const ExecutionHostConversationTurnRequestSchema = z.object({\n schemaVersion: z.literal(EXECUTION_CONTRACT_VERSION),\n kind: z.literal(CONVERSATION_TURN_WORKFLOW),\n invocationId: OpaqueIdSchema,\n prompt: z.string().trim().min(1).max(200_000),\n deadlineAt: TimestampSchema.optional(),\n}).strict();\n\nexport const HeartbeatRunContextSchema = z.object({\n currentDateTime: TimestampSchema,\n intervalMs: z.number().int().positive().max(Number.MAX_SAFE_INTEGER),\n continuationMode: z.enum(['operator', 'agent']).optional(),\n nextRunAt: TimestampSchema.optional(),\n previousRunAt: TimestampSchema.optional(),\n previousRunId: OpaqueIdSchema.optional(),\n}).strict();\n\nexport const ExecutionHostHeartbeatTaskRequestSchema = z.object({\n schemaVersion: z.literal(EXECUTION_CONTRACT_VERSION),\n kind: z.literal(HEARTBEAT_TASK_WORKFLOW),\n invocationId: OpaqueIdSchema,\n taskId: OpaqueIdSchema,\n task: z.string().trim().min(1).max(200_000),\n checkpoint: z.record(z.string(), z.json()).optional(),\n runContext: HeartbeatRunContextSchema,\n model: z.string().trim().min(1).max(512).optional(),\n reasoningEffort: z.enum([\n 'none',\n 'low',\n 'medium',\n 'high',\n 'ultrahigh',\n 'max',\n ]).optional(),\n maxSteps: z.number().int().positive().max(10_000).optional(),\n searchIgnoreDirs: z.array(z.string().min(1).max(1_024)).max(1_000).optional(),\n systemContext: z.string().max(200_000).optional(),\n deadlineAt: TimestampSchema.optional(),\n}).strict();\n\nexport const RuntimePublicResultSchema = z.object({\n outcome: z.enum(['done', 'max_steps', 'error', 'interrupted']),\n summary: z.string().optional(),\n failure: z.object({\n source: z.literal('model'),\n code: z.enum([\n 'authentication',\n 'permission',\n 'quota',\n 'rate_limit',\n 'context_window',\n 'request',\n 'transport',\n 'empty_response',\n 'unknown',\n ]),\n }).strict().optional(),\n}).strict();\n\nconst StreamEnvelopeSchema = z.object({\n schemaVersion: z.literal(EXECUTION_CONTRACT_VERSION),\n invocationId: OpaqueIdSchema,\n runId: OpaqueIdSchema,\n sequence: z.number().int().nonnegative(),\n timestamp: TimestampSchema,\n});\n\nexport const ExecutionHostStreamEventSchema = z.discriminatedUnion('kind', [\n StreamEnvelopeSchema.extend({\n sequence: z.literal(0),\n kind: z.literal('accepted'),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('activity'),\n activity: z.unknown(),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('result'),\n result: RuntimePublicResultSchema,\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('cancelled'),\n reason: z.string(),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('error'),\n error: z.object({\n code: z.string().min(1).max(128).regex(/^[a-z0-9_]+$/),\n message: z.string().min(1).max(1_600),\n }).strict(),\n }).strict(),\n]);\n\nexport const ExecutionHostHeartbeatStreamEventSchema = z.discriminatedUnion(\n 'kind',\n [\n StreamEnvelopeSchema.extend({\n sequence: z.literal(0),\n kind: z.literal('accepted'),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('activity'),\n activity: z.json(),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('result'),\n result: z.record(z.string(), z.json()),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('cancelled'),\n reason: z.string(),\n }).strict(),\n StreamEnvelopeSchema.extend({\n kind: z.literal('error'),\n error: z.object({\n code: z.string().min(1).max(128).regex(/^[a-z0-9_]+$/),\n message: z.string().min(1).max(1_600),\n }).strict(),\n }).strict(),\n ],\n);\n\nexport const HostedExecutionWorkflowSchema = z.enum([\n CONVERSATION_TURN_WORKFLOW,\n HEARTBEAT_TASK_WORKFLOW,\n]);\n\nexport const ExecutionAssertionClaimsSchema = z.object({\n iss: JwtIssuerSchema,\n aud: JwtAudienceSchema,\n contractVersion: z.literal(EXECUTION_CONTRACT_VERSION),\n adopterId: OpaqueIdSchema,\n tenantId: OpaqueIdSchema,\n productSessionId: OpaqueIdSchema,\n runtimeSessionId: RuntimeSessionIdSchema,\n workflow: HostedExecutionWorkflowSchema,\n sub: OpaqueIdSchema,\n jti: OpaqueIdSchema,\n iat: z.number().int().nonnegative(),\n exp: z.number().int().positive(),\n}).passthrough();\n\nexport const McpCapabilityClaimsSchema = z.object({\n iss: JwtIssuerSchema,\n aud: JwtAudienceSchema,\n contractVersion: z.literal(EXECUTION_CONTRACT_VERSION),\n adopterId: OpaqueIdSchema,\n tenantId: OpaqueIdSchema,\n productSessionId: OpaqueIdSchema,\n runtimeSessionId: RuntimeSessionIdSchema,\n invocationId: OpaqueIdSchema,\n workflow: HostedExecutionWorkflowSchema,\n serverId: McpServerIdSchema,\n allowedTools: McpAllowedToolsSchema,\n sub: OpaqueIdSchema,\n jti: OpaqueIdSchema,\n iat: z.number().int().nonnegative(),\n exp: z.number().int().positive(),\n}).passthrough();\n\nexport type ExecutionScope = z.infer<typeof ExecutionScopeSchema>;\nexport type ExecutionHostModelCredential = z.infer<\n typeof ExecutionHostModelCredentialSchema\n>;\nexport type ExecutionHostConversationTurnRequest = z.infer<\n typeof ExecutionHostConversationTurnRequestSchema\n>;\nexport type ExecutionHostHeartbeatTaskRequest = z.infer<\n typeof ExecutionHostHeartbeatTaskRequestSchema\n>;\nexport type RuntimePublicResult = z.infer<typeof RuntimePublicResultSchema>;\nexport type ExecutionHostStreamEvent = z.infer<\n typeof ExecutionHostStreamEventSchema\n>;\nexport type ExecutionHostTerminalEvent = Extract<\n ExecutionHostStreamEvent,\n { kind: 'result' | 'cancelled' | 'error' }\n>;\nexport type ExecutionHostHeartbeatStreamEvent = z.infer<\n typeof ExecutionHostHeartbeatStreamEventSchema\n>;\nexport type ExecutionHostHeartbeatTerminalEvent = Extract<\n ExecutionHostHeartbeatStreamEvent,\n { kind: 'result' | 'cancelled' | 'error' }\n>;\nexport type ExecutionAssertionClaims = z.infer<\n typeof ExecutionAssertionClaimsSchema\n>;\nexport type McpCapabilityClaims = z.infer<typeof McpCapabilityClaimsSchema>;\nexport type HostedExecutionWorkflow = z.infer<\n typeof HostedExecutionWorkflowSchema\n>;\n\nexport function isExecutionHostTerminalEvent(\n event: ExecutionHostStreamEvent,\n): event is ExecutionHostTerminalEvent {\n return event.kind === 'result'\n || event.kind === 'cancelled'\n || event.kind === 'error';\n}\n\nexport function isExecutionHostHeartbeatTerminalEvent(\n event: ExecutionHostHeartbeatStreamEvent,\n): event is ExecutionHostHeartbeatTerminalEvent {\n return event.kind === 'result'\n || event.kind === 'cancelled'\n || event.kind === 'error';\n}\n\nexport function isSafeWebUrl(url: URL): boolean {\n const loopback = ['127.0.0.1', '[::1]', 'localhost'].includes(url.hostname);\n return (url.protocol === 'https:' || (url.protocol === 'http:' && loopback))\n && !url.username\n && !url.password\n && !url.search\n && !url.hash;\n}\n\n/** Explicit Docker Desktop bridge exception for isolated local composition. */\nexport function isDockerLocalWebUrl(url: URL): boolean {\n return url.protocol === 'http:'\n && url.hostname === 'host.docker.internal'\n && !url.username\n && !url.password\n && !url.search\n && !url.hash;\n}\n"]}
|
|
@@ -39,7 +39,7 @@ export class HostedConversationTurnService {
|
|
|
39
39
|
if (this.#allowedTools && !mcpCapability) {
|
|
40
40
|
throw new HostedConversationConfigurationError('Hosted conversation tool policy requires an MCP-capable execution authority.');
|
|
41
41
|
}
|
|
42
|
-
const
|
|
42
|
+
const modelCredential = await this.#modelCredentials.resolveModelCredential({
|
|
43
43
|
scope: input.scope,
|
|
44
44
|
invocationId: input.invocationId,
|
|
45
45
|
signal: input.signal,
|
|
@@ -53,7 +53,7 @@ export class HostedConversationTurnService {
|
|
|
53
53
|
...(input.signal ? { signal: input.signal } : {}),
|
|
54
54
|
executionAssertion: issued.executionAssertion(),
|
|
55
55
|
...(mcpCapability ? { mcpCapability } : {}),
|
|
56
|
-
|
|
56
|
+
modelCredential,
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
}
|