agenthooksprotocol 0.1.0 → 0.2.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 +41 -0
- package/dist/src/client/composition.d.ts +2 -0
- package/dist/src/client/composition.d.ts.map +1 -1
- package/dist/src/client/composition.js +14 -6
- package/dist/src/client/composition.js.map +1 -1
- package/dist/src/client/content.d.ts +58 -20
- package/dist/src/client/content.d.ts.map +1 -1
- package/dist/src/client/content.js +358 -105
- package/dist/src/client/content.js.map +1 -1
- package/dist/src/client/hooks.d.ts +4 -0
- package/dist/src/client/hooks.d.ts.map +1 -1
- package/dist/src/client/hooks.js +162 -54
- package/dist/src/client/hooks.js.map +1 -1
- package/dist/src/client/index.d.ts +1 -0
- package/dist/src/client/index.d.ts.map +1 -1
- package/dist/src/client/index.js +1 -0
- package/dist/src/client/index.js.map +1 -1
- package/dist/src/client/types.d.ts +6 -3
- package/dist/src/client/types.d.ts.map +1 -1
- package/dist/src/client/types.js.map +1 -1
- package/dist/src/content-upload.d.ts +9 -10
- package/dist/src/content-upload.d.ts.map +1 -1
- package/dist/src/content-upload.js +8 -4
- package/dist/src/content-upload.js.map +1 -1
- package/dist/src/draft/generated.d.ts +73 -47
- package/dist/src/draft/generated.d.ts.map +1 -1
- package/dist/src/draft/generated.js +502 -251
- package/dist/src/draft/generated.js.map +1 -1
- package/dist/src/draft/index.d.ts +4 -1
- package/dist/src/draft/index.d.ts.map +1 -1
- package/dist/src/draft/index.js +2 -0
- package/dist/src/draft/index.js.map +1 -1
- package/dist/src/draft/schemas.d.ts +112 -40
- package/dist/src/draft/schemas.d.ts.map +1 -1
- package/dist/src/draft/schemas.js +158 -120
- package/dist/src/draft/schemas.js.map +1 -1
- package/dist/src/draft-runtime.d.ts +5 -5
- package/dist/src/draft-runtime.d.ts.map +1 -1
- package/dist/src/draft-runtime.js +3 -5
- package/dist/src/draft-runtime.js.map +1 -1
- package/dist/src/server/attachments.d.ts +2 -2
- package/dist/src/server/attachments.d.ts.map +1 -1
- package/dist/src/server/attachments.js +3 -3
- package/dist/src/server/attachments.js.map +1 -1
- package/dist/src/server/hooks.d.ts.map +1 -1
- package/dist/src/server/hooks.js +4 -2
- package/dist/src/server/hooks.js.map +1 -1
- package/dist/src/server/index.d.ts +3 -1
- package/dist/src/server/index.d.ts.map +1 -1
- package/dist/src/server/index.js +1 -0
- package/dist/src/server/index.js.map +1 -1
- package/package.json +1 -1
- package/src/client/composition.ts +15 -6
- package/src/client/content.ts +350 -113
- package/src/client/hooks.ts +188 -60
- package/src/client/index.ts +2 -0
- package/src/client/types.ts +6 -3
- package/src/content-upload.ts +14 -13
- package/src/draft/ahp-codegen.lock.json +14 -6
- package/src/draft/generated.ts +733 -427
- package/src/draft/index.ts +6 -1
- package/src/draft/schemas.ts +160 -120
- package/src/draft-runtime.ts +7 -9
- package/src/server/attachments.ts +5 -5
- package/src/server/hooks.ts +3 -2
- package/src/server/index.ts +5 -0
package/src/draft/index.ts
CHANGED
|
@@ -233,7 +233,7 @@ export type {
|
|
|
233
233
|
|
|
234
234
|
export type {
|
|
235
235
|
UploadConfiguration,
|
|
236
|
-
|
|
236
|
+
ContentUploadReceipt,
|
|
237
237
|
NormalizedContentInput,
|
|
238
238
|
NormalizedContentView,
|
|
239
239
|
} from "../content-upload.js";
|
|
@@ -244,3 +244,8 @@ export type {
|
|
|
244
244
|
ObservationEvent,
|
|
245
245
|
ObservationNotification,
|
|
246
246
|
} from "../observation.js";
|
|
247
|
+
|
|
248
|
+
export { contentReference } from "../content-upload.js";
|
|
249
|
+
|
|
250
|
+
export { effectNames, supports } from "./generated.js";
|
|
251
|
+
export type { EffectName } from "./generated.js";
|
package/src/draft/schemas.ts
CHANGED
|
@@ -2671,16 +2671,6 @@ export const schemas = [
|
|
|
2671
2671
|
type: "string",
|
|
2672
2672
|
minLength: 1,
|
|
2673
2673
|
},
|
|
2674
|
-
size: {
|
|
2675
|
-
type: "integer",
|
|
2676
|
-
minimum: 0,
|
|
2677
|
-
},
|
|
2678
|
-
sha256: {
|
|
2679
|
-
type: "string",
|
|
2680
|
-
pattern: "^[a-f0-9]{64}$",
|
|
2681
|
-
minLength: 64,
|
|
2682
|
-
maxLength: 64,
|
|
2683
|
-
},
|
|
2684
2674
|
synthesized: {
|
|
2685
2675
|
type: "boolean",
|
|
2686
2676
|
description:
|
|
@@ -2688,6 +2678,18 @@ export const schemas = [
|
|
|
2688
2678
|
},
|
|
2689
2679
|
},
|
|
2690
2680
|
additionalProperties: false,
|
|
2681
|
+
allOf: [
|
|
2682
|
+
{
|
|
2683
|
+
not: {
|
|
2684
|
+
required: ["size"],
|
|
2685
|
+
},
|
|
2686
|
+
},
|
|
2687
|
+
{
|
|
2688
|
+
not: {
|
|
2689
|
+
required: ["sha256"],
|
|
2690
|
+
},
|
|
2691
|
+
},
|
|
2692
|
+
],
|
|
2691
2693
|
},
|
|
2692
2694
|
{
|
|
2693
2695
|
type: "object",
|
|
@@ -2881,27 +2883,29 @@ export const schemas = [
|
|
|
2881
2883
|
$id: "https://agenthooksprotocol.org/schemas/draft/content-reference.schema.json",
|
|
2882
2884
|
title: "AHP content-reference (Draft)",
|
|
2883
2885
|
type: "object",
|
|
2884
|
-
required: ["ref"
|
|
2886
|
+
required: ["ref"],
|
|
2885
2887
|
properties: {
|
|
2886
2888
|
ref: {
|
|
2887
2889
|
type: "string",
|
|
2888
2890
|
minLength: 1,
|
|
2889
2891
|
},
|
|
2890
|
-
size: {
|
|
2891
|
-
type: "integer",
|
|
2892
|
-
minimum: 0,
|
|
2893
|
-
},
|
|
2894
|
-
sha256: {
|
|
2895
|
-
type: "string",
|
|
2896
|
-
pattern: "^[a-f0-9]{64}$",
|
|
2897
|
-
minLength: 64,
|
|
2898
|
-
maxLength: 64,
|
|
2899
|
-
},
|
|
2900
2892
|
},
|
|
2901
2893
|
additionalProperties: false,
|
|
2902
2894
|
$comment: "Mutable AHP draft. ",
|
|
2903
2895
|
description:
|
|
2904
|
-
"Receiver-allocated immutable
|
|
2896
|
+
"Receiver-allocated immutable content reference. ref is opaque, not a URL or authorization grant; access is authorized by credential-derived scope. Upload size and digest belong only in the separate content-upload-receipt, never this event reference.",
|
|
2897
|
+
allOf: [
|
|
2898
|
+
{
|
|
2899
|
+
not: {
|
|
2900
|
+
required: ["size"],
|
|
2901
|
+
},
|
|
2902
|
+
},
|
|
2903
|
+
{
|
|
2904
|
+
not: {
|
|
2905
|
+
required: ["sha256"],
|
|
2906
|
+
},
|
|
2907
|
+
},
|
|
2908
|
+
],
|
|
2905
2909
|
},
|
|
2906
2910
|
{
|
|
2907
2911
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
@@ -2939,6 +2943,33 @@ export const schemas = [
|
|
|
2939
2943
|
description:
|
|
2940
2944
|
"Select by descriptor category; reasoning takes its own category, otherwise classify by media type, not enclosing message role. Unlisted categories use required default. Selection never grants authorization.",
|
|
2941
2945
|
},
|
|
2946
|
+
{
|
|
2947
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
2948
|
+
$id: "https://agenthooksprotocol.org/schemas/draft/content-upload-receipt.schema.json",
|
|
2949
|
+
title: "AHP ContentUploadReceipt (Draft)",
|
|
2950
|
+
type: "object",
|
|
2951
|
+
required: ["ref", "size", "sha256"],
|
|
2952
|
+
properties: {
|
|
2953
|
+
ref: {
|
|
2954
|
+
type: "string",
|
|
2955
|
+
minLength: 1,
|
|
2956
|
+
},
|
|
2957
|
+
size: {
|
|
2958
|
+
type: "integer",
|
|
2959
|
+
minimum: 0,
|
|
2960
|
+
},
|
|
2961
|
+
sha256: {
|
|
2962
|
+
type: "string",
|
|
2963
|
+
pattern: "^[a-f0-9]{64}$",
|
|
2964
|
+
minLength: 64,
|
|
2965
|
+
maxLength: 64,
|
|
2966
|
+
},
|
|
2967
|
+
},
|
|
2968
|
+
additionalProperties: false,
|
|
2969
|
+
$comment: "Mutable AHP draft. ",
|
|
2970
|
+
description:
|
|
2971
|
+
"HTTP 201 upload confirmation. ref identifies receiver-allocated immutable bytes; size counts exact octets and sha256 is their lowercase SHA-256 digest. Senders verify both before publishing only ref in an event body. This receipt is not event acknowledgement or proof of durable storage.",
|
|
2972
|
+
},
|
|
2942
2973
|
{
|
|
2943
2974
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
2944
2975
|
$id: "https://agenthooksprotocol.org/schemas/draft/content-upload.schema.json",
|
|
@@ -3166,6 +3197,111 @@ export const schemas = [
|
|
|
3166
3197
|
],
|
|
3167
3198
|
title: "AHP Effect (Draft)",
|
|
3168
3199
|
},
|
|
3200
|
+
{
|
|
3201
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
3202
|
+
$id: "https://agenthooksprotocol.org/schemas/draft/event.schema.json",
|
|
3203
|
+
title: "AHP Event (Draft)",
|
|
3204
|
+
$comment:
|
|
3205
|
+
"Mutable AHP draft. One shared event union; intercept eligibility is constrained at the request level.",
|
|
3206
|
+
oneOf: [
|
|
3207
|
+
{
|
|
3208
|
+
$ref: "tool-before.schema.json",
|
|
3209
|
+
},
|
|
3210
|
+
{
|
|
3211
|
+
$ref: "tool-after.schema.json",
|
|
3212
|
+
},
|
|
3213
|
+
{
|
|
3214
|
+
$ref: "session-start.schema.json",
|
|
3215
|
+
},
|
|
3216
|
+
{
|
|
3217
|
+
$ref: "session-end.schema.json",
|
|
3218
|
+
},
|
|
3219
|
+
{
|
|
3220
|
+
$ref: "catalogue-event.schema.json#/$defs/config.change.before",
|
|
3221
|
+
},
|
|
3222
|
+
{
|
|
3223
|
+
$ref: "catalogue-event.schema.json#/$defs/config.change.after",
|
|
3224
|
+
},
|
|
3225
|
+
{
|
|
3226
|
+
$ref: "catalogue-event.schema.json#/$defs/turn.start",
|
|
3227
|
+
},
|
|
3228
|
+
{
|
|
3229
|
+
$ref: "catalogue-event.schema.json#/$defs/turn.finish.before",
|
|
3230
|
+
},
|
|
3231
|
+
{
|
|
3232
|
+
$ref: "catalogue-event.schema.json#/$defs/turn.end",
|
|
3233
|
+
},
|
|
3234
|
+
{
|
|
3235
|
+
$ref: "catalogue-event.schema.json#/$defs/turn.progress",
|
|
3236
|
+
},
|
|
3237
|
+
{
|
|
3238
|
+
$ref: "catalogue-event.schema.json#/$defs/model.request.before",
|
|
3239
|
+
},
|
|
3240
|
+
{
|
|
3241
|
+
$ref: "catalogue-event.schema.json#/$defs/model.response.after",
|
|
3242
|
+
},
|
|
3243
|
+
{
|
|
3244
|
+
$ref: "catalogue-event.schema.json#/$defs/model.error",
|
|
3245
|
+
},
|
|
3246
|
+
{
|
|
3247
|
+
$ref: "catalogue-event.schema.json#/$defs/model.switch.before",
|
|
3248
|
+
},
|
|
3249
|
+
{
|
|
3250
|
+
$ref: "catalogue-event.schema.json#/$defs/model.switch.after",
|
|
3251
|
+
},
|
|
3252
|
+
{
|
|
3253
|
+
$ref: "catalogue-event.schema.json#/$defs/tool.permission.request",
|
|
3254
|
+
},
|
|
3255
|
+
{
|
|
3256
|
+
$ref: "catalogue-event.schema.json#/$defs/tool.permission.resolved",
|
|
3257
|
+
},
|
|
3258
|
+
{
|
|
3259
|
+
$ref: "catalogue-event.schema.json#/$defs/tool.progress",
|
|
3260
|
+
},
|
|
3261
|
+
{
|
|
3262
|
+
$ref: "catalogue-event.schema.json#/$defs/tool.batch.after",
|
|
3263
|
+
},
|
|
3264
|
+
{
|
|
3265
|
+
$ref: "catalogue-event.schema.json#/$defs/context.compact.before",
|
|
3266
|
+
},
|
|
3267
|
+
{
|
|
3268
|
+
$ref: "catalogue-event.schema.json#/$defs/context.compact.after",
|
|
3269
|
+
},
|
|
3270
|
+
{
|
|
3271
|
+
$ref: "catalogue-event.schema.json#/$defs/task.change.before",
|
|
3272
|
+
},
|
|
3273
|
+
{
|
|
3274
|
+
$ref: "catalogue-event.schema.json#/$defs/task.change.after",
|
|
3275
|
+
},
|
|
3276
|
+
{
|
|
3277
|
+
$ref: "catalogue-event.schema.json#/$defs/user.attention",
|
|
3278
|
+
},
|
|
3279
|
+
{
|
|
3280
|
+
$ref: "catalogue-event.schema.json#/$defs/user.elicitation.request",
|
|
3281
|
+
},
|
|
3282
|
+
{
|
|
3283
|
+
$ref: "catalogue-event.schema.json#/$defs/user.elicitation.result",
|
|
3284
|
+
},
|
|
3285
|
+
{
|
|
3286
|
+
$ref: "catalogue-event.schema.json#/$defs/user.message.inbound",
|
|
3287
|
+
},
|
|
3288
|
+
{
|
|
3289
|
+
$ref: "catalogue-event.schema.json#/$defs/user.message.outbound",
|
|
3290
|
+
},
|
|
3291
|
+
{
|
|
3292
|
+
$ref: "catalogue-event.schema.json#/$defs/workspace.change.before",
|
|
3293
|
+
},
|
|
3294
|
+
{
|
|
3295
|
+
$ref: "catalogue-event.schema.json#/$defs/workspace.change.after",
|
|
3296
|
+
},
|
|
3297
|
+
{
|
|
3298
|
+
$ref: "catalogue-event.schema.json#/$defs/file.changed",
|
|
3299
|
+
},
|
|
3300
|
+
{
|
|
3301
|
+
$ref: "catalogue-event.schema.json#/$defs/hook.failure",
|
|
3302
|
+
},
|
|
3303
|
+
],
|
|
3304
|
+
},
|
|
3169
3305
|
{
|
|
3170
3306
|
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
3171
3307
|
$id: "https://agenthooksprotocol.org/schemas/draft/execution-event.schema.json",
|
|
@@ -6400,6 +6536,7 @@ export const schemas = [
|
|
|
6400
6536
|
$ref: "common.schema.json#/$defs/protocolVersion",
|
|
6401
6537
|
},
|
|
6402
6538
|
event: {
|
|
6539
|
+
$ref: "event.schema.json",
|
|
6403
6540
|
oneOf: [
|
|
6404
6541
|
{
|
|
6405
6542
|
$ref: "tool-before.schema.json",
|
|
@@ -7546,104 +7683,7 @@ export const schemas = [
|
|
|
7546
7683
|
$ref: "common.schema.json#/$defs/protocolVersion",
|
|
7547
7684
|
},
|
|
7548
7685
|
event: {
|
|
7549
|
-
|
|
7550
|
-
{
|
|
7551
|
-
$ref: "tool-before.schema.json",
|
|
7552
|
-
},
|
|
7553
|
-
{
|
|
7554
|
-
$ref: "tool-after.schema.json",
|
|
7555
|
-
},
|
|
7556
|
-
{
|
|
7557
|
-
$ref: "session-start.schema.json",
|
|
7558
|
-
},
|
|
7559
|
-
{
|
|
7560
|
-
$ref: "session-end.schema.json",
|
|
7561
|
-
},
|
|
7562
|
-
{
|
|
7563
|
-
$ref: "catalogue-event.schema.json#/$defs/config.change.before",
|
|
7564
|
-
},
|
|
7565
|
-
{
|
|
7566
|
-
$ref: "catalogue-event.schema.json#/$defs/config.change.after",
|
|
7567
|
-
},
|
|
7568
|
-
{
|
|
7569
|
-
$ref: "catalogue-event.schema.json#/$defs/turn.start",
|
|
7570
|
-
},
|
|
7571
|
-
{
|
|
7572
|
-
$ref: "catalogue-event.schema.json#/$defs/turn.finish.before",
|
|
7573
|
-
},
|
|
7574
|
-
{
|
|
7575
|
-
$ref: "catalogue-event.schema.json#/$defs/turn.end",
|
|
7576
|
-
},
|
|
7577
|
-
{
|
|
7578
|
-
$ref: "catalogue-event.schema.json#/$defs/turn.progress",
|
|
7579
|
-
},
|
|
7580
|
-
{
|
|
7581
|
-
$ref: "catalogue-event.schema.json#/$defs/model.request.before",
|
|
7582
|
-
},
|
|
7583
|
-
{
|
|
7584
|
-
$ref: "catalogue-event.schema.json#/$defs/model.response.after",
|
|
7585
|
-
},
|
|
7586
|
-
{
|
|
7587
|
-
$ref: "catalogue-event.schema.json#/$defs/model.error",
|
|
7588
|
-
},
|
|
7589
|
-
{
|
|
7590
|
-
$ref: "catalogue-event.schema.json#/$defs/model.switch.before",
|
|
7591
|
-
},
|
|
7592
|
-
{
|
|
7593
|
-
$ref: "catalogue-event.schema.json#/$defs/model.switch.after",
|
|
7594
|
-
},
|
|
7595
|
-
{
|
|
7596
|
-
$ref: "catalogue-event.schema.json#/$defs/tool.permission.request",
|
|
7597
|
-
},
|
|
7598
|
-
{
|
|
7599
|
-
$ref: "catalogue-event.schema.json#/$defs/tool.permission.resolved",
|
|
7600
|
-
},
|
|
7601
|
-
{
|
|
7602
|
-
$ref: "catalogue-event.schema.json#/$defs/tool.progress",
|
|
7603
|
-
},
|
|
7604
|
-
{
|
|
7605
|
-
$ref: "catalogue-event.schema.json#/$defs/tool.batch.after",
|
|
7606
|
-
},
|
|
7607
|
-
{
|
|
7608
|
-
$ref: "catalogue-event.schema.json#/$defs/context.compact.before",
|
|
7609
|
-
},
|
|
7610
|
-
{
|
|
7611
|
-
$ref: "catalogue-event.schema.json#/$defs/context.compact.after",
|
|
7612
|
-
},
|
|
7613
|
-
{
|
|
7614
|
-
$ref: "catalogue-event.schema.json#/$defs/task.change.before",
|
|
7615
|
-
},
|
|
7616
|
-
{
|
|
7617
|
-
$ref: "catalogue-event.schema.json#/$defs/task.change.after",
|
|
7618
|
-
},
|
|
7619
|
-
{
|
|
7620
|
-
$ref: "catalogue-event.schema.json#/$defs/user.attention",
|
|
7621
|
-
},
|
|
7622
|
-
{
|
|
7623
|
-
$ref: "catalogue-event.schema.json#/$defs/user.elicitation.request",
|
|
7624
|
-
},
|
|
7625
|
-
{
|
|
7626
|
-
$ref: "catalogue-event.schema.json#/$defs/user.elicitation.result",
|
|
7627
|
-
},
|
|
7628
|
-
{
|
|
7629
|
-
$ref: "catalogue-event.schema.json#/$defs/user.message.inbound",
|
|
7630
|
-
},
|
|
7631
|
-
{
|
|
7632
|
-
$ref: "catalogue-event.schema.json#/$defs/user.message.outbound",
|
|
7633
|
-
},
|
|
7634
|
-
{
|
|
7635
|
-
$ref: "catalogue-event.schema.json#/$defs/workspace.change.before",
|
|
7636
|
-
},
|
|
7637
|
-
{
|
|
7638
|
-
$ref: "catalogue-event.schema.json#/$defs/workspace.change.after",
|
|
7639
|
-
},
|
|
7640
|
-
{
|
|
7641
|
-
$ref: "catalogue-event.schema.json#/$defs/file.changed",
|
|
7642
|
-
},
|
|
7643
|
-
{
|
|
7644
|
-
$ref: "catalogue-event.schema.json#/$defs/hook.failure",
|
|
7645
|
-
},
|
|
7646
|
-
],
|
|
7686
|
+
$ref: "event.schema.json",
|
|
7647
7687
|
},
|
|
7648
7688
|
},
|
|
7649
7689
|
},
|
package/src/draft-runtime.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { validateEffect } from "./draft/index.js";
|
|
2
|
-
import {
|
|
2
|
+
import { validateUploadReceipt, type ContentUploadReceipt } from "./content-upload.js";
|
|
3
3
|
/** Synthetic semantic harness. Wire acceptance remains the canonical validator's job. */
|
|
4
4
|
import { stageResponse, object, type PendingState } from "./draft-atomic.js";
|
|
5
5
|
import type { Effect, Capabilities } from "./draft/index.js";
|
|
@@ -211,7 +211,7 @@ export interface ContentView {
|
|
|
211
211
|
/** Receiver storage scoped by the host's authenticated principal, not wire claims. */
|
|
212
212
|
export class ContentReceiver {
|
|
213
213
|
private stored = new Map<string, Uint8Array>();
|
|
214
|
-
async upload(scope: string, bytes: Uint8Array): Promise<
|
|
214
|
+
async upload(scope: string, bytes: Uint8Array): Promise<ContentUploadReceipt> {
|
|
215
215
|
if (!scope || !(bytes instanceof Uint8Array))
|
|
216
216
|
throw Error("Authenticated scope and binary bytes required");
|
|
217
217
|
const snapshot = bytes.slice();
|
|
@@ -239,7 +239,7 @@ export async function prepareContent(
|
|
|
239
239
|
mode: "intercept" | "observe";
|
|
240
240
|
failClosed: boolean;
|
|
241
241
|
timeoutMs?: number;
|
|
242
|
-
upload(bytes: Uint8Array): Promise<
|
|
242
|
+
upload(bytes: Uint8Array): Promise<ContentUploadReceipt>;
|
|
243
243
|
},
|
|
244
244
|
): Promise<ContentView[]> {
|
|
245
245
|
const result: ContentView[] = [];
|
|
@@ -257,7 +257,7 @@ export async function prepareContent(
|
|
|
257
257
|
await crypto.subtle.digest("SHA-256", bytes),
|
|
258
258
|
);
|
|
259
259
|
let timer: ReturnType<typeof setTimeout> | undefined;
|
|
260
|
-
let confirmed:
|
|
260
|
+
let confirmed: ContentUploadReceipt;
|
|
261
261
|
try {
|
|
262
262
|
confirmed = await Promise.race([
|
|
263
263
|
options.upload(bytes.slice()),
|
|
@@ -274,10 +274,8 @@ export async function prepareContent(
|
|
|
274
274
|
const sha256 = Array.from(hash, (byte) =>
|
|
275
275
|
byte.toString(16).padStart(2, "0"),
|
|
276
276
|
).join("");
|
|
277
|
-
const body =
|
|
277
|
+
const body = validateUploadReceipt(confirmed, bytes.length, sha256);
|
|
278
278
|
view.ref = body.ref;
|
|
279
|
-
view.sizeBytes = body.size;
|
|
280
|
-
view.sha256 = body.sha256;
|
|
281
279
|
} catch {
|
|
282
280
|
view.gap = "transfer_failed";
|
|
283
281
|
}
|
|
@@ -350,10 +348,10 @@ export function actualTaskChange<T>(
|
|
|
350
348
|
after: structuredClone(after),
|
|
351
349
|
};
|
|
352
350
|
}
|
|
353
|
-
export { uploadContent, prepareWireContent } from "./content-upload.js";
|
|
351
|
+
export { uploadContent, prepareWireContent, contentReference } from "./content-upload.js";
|
|
354
352
|
export type {
|
|
355
353
|
UploadConfiguration,
|
|
356
|
-
|
|
354
|
+
ContentUploadReceipt,
|
|
357
355
|
NormalizedContentInput,
|
|
358
356
|
NormalizedContentView,
|
|
359
357
|
} from "./content-upload.js";
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { createHash } from "node:crypto";
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
type
|
|
3
|
+
parseContentUploadReceipt,
|
|
4
|
+
type ContentUploadReceipt,
|
|
5
5
|
} from "../draft/generated.js";
|
|
6
6
|
import { validateWire } from "../client/validation.js";
|
|
7
7
|
|
|
@@ -113,10 +113,10 @@ function parse(request: Request): Upload {
|
|
|
113
113
|
* Call only after an authorized storage write consumed body to successful EOF
|
|
114
114
|
* and the immutable reference is synchronously available to the receiver.
|
|
115
115
|
*/
|
|
116
|
-
function response(descriptor:
|
|
117
|
-
if (validateWire("content-
|
|
116
|
+
function response(descriptor: ContentUploadReceipt): Response {
|
|
117
|
+
if (validateWire("content-upload-receipt", descriptor).length !== 0)
|
|
118
118
|
throw new UploadError("Invalid content descriptor");
|
|
119
|
-
const decoded =
|
|
119
|
+
const decoded = parseContentUploadReceipt(descriptor);
|
|
120
120
|
if (!decoded.ok || !Number.isSafeInteger(decoded.value.size))
|
|
121
121
|
throw new UploadError("Invalid content descriptor");
|
|
122
122
|
return new Response(JSON.stringify(decoded.value), {
|
package/src/server/hooks.ts
CHANGED
|
@@ -92,8 +92,9 @@ function supported(
|
|
|
92
92
|
effect.type === "return" &&
|
|
93
93
|
request.params.event.type === "user.elicitation.request"
|
|
94
94
|
) {
|
|
95
|
-
const
|
|
96
|
-
if (!
|
|
95
|
+
const elicitation = request.params.event.elicitation;
|
|
96
|
+
if (!object(elicitation) || typeof elicitation.mode !== "string") return false;
|
|
97
|
+
if (!caps.elicitation?.[elicitation.mode]) return false;
|
|
97
98
|
}
|
|
98
99
|
return true;
|
|
99
100
|
});
|
package/src/server/index.ts
CHANGED
|
@@ -9,6 +9,8 @@ export { attachments, UploadError } from "./attachments.js";
|
|
|
9
9
|
export type { Upload } from "./attachments.js";
|
|
10
10
|
export type {
|
|
11
11
|
ContentReference,
|
|
12
|
+
ContentUploadReceipt,
|
|
13
|
+
Event,
|
|
12
14
|
InterceptRequest,
|
|
13
15
|
ObserveNotification,
|
|
14
16
|
CapabilitiesRequest,
|
|
@@ -16,3 +18,6 @@ export type {
|
|
|
16
18
|
} from "../draft/generated.js";
|
|
17
19
|
|
|
18
20
|
export { effects } from "../draft/generated.js";
|
|
21
|
+
|
|
22
|
+
export { effectNames, supports } from "../draft/generated.js";
|
|
23
|
+
export type { EffectName } from "../draft/generated.js";
|