dsh-a2a-server 0.1.1 → 0.3.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.
Files changed (86) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/CHANGELOG.zh-CN.md +28 -0
  3. package/README.md +151 -54
  4. package/README.zh-CN.md +113 -53
  5. package/cordis.patch.yml +10 -6
  6. package/lib/briefing.d.ts +39 -0
  7. package/lib/briefing.d.ts.map +1 -0
  8. package/lib/briefing.js +108 -0
  9. package/lib/briefing.js.map +1 -0
  10. package/lib/config.d.ts +69 -22
  11. package/lib/config.d.ts.map +1 -1
  12. package/lib/config.js +76 -6
  13. package/lib/config.js.map +1 -1
  14. package/lib/contexts.d.ts +9 -4
  15. package/lib/contexts.d.ts.map +1 -1
  16. package/lib/contexts.js +7 -13
  17. package/lib/contexts.js.map +1 -1
  18. package/lib/index.d.ts +1 -26
  19. package/lib/index.d.ts.map +1 -1
  20. package/lib/index.js +420 -408
  21. package/lib/index.js.map +1 -1
  22. package/lib/management.d.ts +5 -0
  23. package/lib/management.d.ts.map +1 -0
  24. package/lib/management.js +74 -0
  25. package/lib/management.js.map +1 -0
  26. package/lib/projection.d.ts +67 -22
  27. package/lib/projection.d.ts.map +1 -1
  28. package/lib/projection.js +30 -11
  29. package/lib/projection.js.map +1 -1
  30. package/lib/protocol/card.d.ts +25 -7
  31. package/lib/protocol/card.d.ts.map +1 -1
  32. package/lib/protocol/card.js +35 -14
  33. package/lib/protocol/card.js.map +1 -1
  34. package/lib/protocol/index.d.ts +10 -10
  35. package/lib/protocol/index.d.ts.map +1 -1
  36. package/lib/protocol/index.js +8 -8
  37. package/lib/protocol/index.js.map +1 -1
  38. package/lib/protocol/jsonrpc.d.ts +54 -6
  39. package/lib/protocol/jsonrpc.d.ts.map +1 -1
  40. package/lib/protocol/jsonrpc.js +70 -8
  41. package/lib/protocol/jsonrpc.js.map +1 -1
  42. package/lib/protocol/parse.d.ts +79 -0
  43. package/lib/protocol/parse.d.ts.map +1 -0
  44. package/lib/protocol/parse.js +249 -0
  45. package/lib/protocol/parse.js.map +1 -0
  46. package/lib/protocol/sse.d.ts +6 -3
  47. package/lib/protocol/sse.d.ts.map +1 -1
  48. package/lib/protocol/sse.js +4 -2
  49. package/lib/protocol/sse.js.map +1 -1
  50. package/lib/protocol/wire.d.ts +165 -54
  51. package/lib/protocol/wire.d.ts.map +1 -1
  52. package/lib/protocol/wire.js +54 -9
  53. package/lib/protocol/wire.js.map +1 -1
  54. package/lib/router.d.ts +55 -1
  55. package/lib/router.d.ts.map +1 -1
  56. package/lib/router.js +419 -137
  57. package/lib/router.js.map +1 -1
  58. package/lib/security.d.ts +37 -3
  59. package/lib/security.d.ts.map +1 -1
  60. package/lib/security.js +48 -4
  61. package/lib/security.js.map +1 -1
  62. package/lib/state.d.ts +37 -0
  63. package/lib/state.d.ts.map +1 -0
  64. package/lib/state.js +146 -0
  65. package/lib/state.js.map +1 -0
  66. package/lib/tasks.d.ts +4 -0
  67. package/lib/tasks.d.ts.map +1 -1
  68. package/lib/tasks.js +23 -5
  69. package/lib/tasks.js.map +1 -1
  70. package/lib/types.d.ts +12 -3
  71. package/lib/types.d.ts.map +1 -1
  72. package/lib/types.js +1 -1
  73. package/lib/types.js.map +1 -1
  74. package/lib/version.d.ts +20 -0
  75. package/lib/version.d.ts.map +1 -0
  76. package/lib/version.js +20 -0
  77. package/lib/version.js.map +1 -0
  78. package/lib/workspace-read.d.ts +9 -0
  79. package/lib/workspace-read.d.ts.map +1 -0
  80. package/lib/workspace-read.js +152 -0
  81. package/lib/workspace-read.js.map +1 -0
  82. package/package.json +39 -30
  83. package/lib/protocol/normalize.d.ts +0 -72
  84. package/lib/protocol/normalize.d.ts.map +0 -1
  85. package/lib/protocol/normalize.js +0 -278
  86. package/lib/protocol/normalize.js.map +0 -1
@@ -1,23 +1,23 @@
1
1
  /**
2
- * The A2A wire protocol as a dependency-free library.
2
+ * The A2A v1.0 wire protocol as a dependency-free library.
3
3
  *
4
4
  * Nothing here touches Cordis, HTTP, or the harness: it is types, framing,
5
- * dialect normalization, and document construction, so the spec's own JSON
6
- * examples can be used as golden tests without booting anything.
5
+ * inbound parsing, and document construction, so the spec's own JSON examples
6
+ * can be used as golden tests without booting anything.
7
7
  *
8
8
  * @module dsh-a2a/protocol
9
9
  */
10
10
  export { A2AContextId, A2ATaskId } from './brand.ts';
11
11
  export type { A2AContextId as A2AContextIdType, A2ATaskId as A2ATaskIdType } from './brand.ts';
12
- export { TERMINAL_STATES, isTerminal, } from './wire.ts';
13
- export type { A2AAgentCard, A2AAgentSkill, A2AArtifact, A2ADataPart, A2ADialect, A2AFilePart, A2AMessage, A2AMessageSendConfiguration, A2AMessageSendParams, A2APart, A2APushNotificationConfig, A2ARole, A2AStreamEvent, A2ATask, A2ATaskArtifactUpdateEvent, A2ATaskState, A2ATaskStatus, A2ATaskStatusUpdateEvent, A2ATextPart, } from './wire.ts';
14
- export { A2ARpcError, ERR_CONTENT_TYPE_NOT_SUPPORTED, ERR_INTERNAL, ERR_INVALID_PARAMS, ERR_INVALID_REQUEST, ERR_METHOD_NOT_FOUND, ERR_PARSE, ERR_PUSH_NOT_SUPPORTED, ERR_TASK_NOT_CANCELABLE, ERR_TASK_NOT_FOUND, ERR_UNSUPPORTED_OPERATION, invalidParams, jsonRpcError, jsonRpcResult, taskNotFound, } from './jsonrpc.ts';
12
+ export { A2A_PROTOCOL_VERSION, TASK_STATES, TERMINAL_STATES, isTerminal, streamArtifactUpdate, streamStatusUpdate, streamTask, } from './wire.ts';
13
+ export type { A2AAgentCapabilities, A2AAgentCard, A2AAgentInterface, A2AAgentSkill, A2AArtifact, A2ADataPart, A2AFilePart, A2AListTasksParams, A2AListTasksResult, A2AMessage, A2APart, A2APushNotificationConfig, A2ARole, A2ASecurityRequirement, A2ASendMessageConfiguration, A2ASendMessageRequest, A2ASendMessageResponse, A2AStreamResponse, A2ATask, A2ATaskArtifactUpdateEvent, A2ATaskPushNotificationConfig, A2ATaskState, A2ATaskStatus, A2ATaskStatusUpdateEvent, A2ATextPart, } from './wire.ts';
14
+ export { A2A_ERROR_DOMAIN, A2ARpcError, ERR_CONTENT_TYPE_NOT_SUPPORTED, ERR_EXTENDED_CARD_NOT_CONFIGURED, ERR_EXTENSION_SUPPORT_REQUIRED, ERR_INTERNAL, ERR_INVALID_AGENT_RESPONSE, ERR_INVALID_PARAMS, ERR_INVALID_REQUEST, ERR_METHOD_NOT_FOUND, ERR_PARSE, ERR_PUSH_NOT_SUPPORTED, ERR_TASK_NOT_CANCELABLE, ERR_TASK_NOT_FOUND, ERR_UNSUPPORTED_OPERATION, ERR_VERSION_NOT_SUPPORTED, errorDetails, invalidParams, jsonRpcError, jsonRpcResult, taskNotFound, unsupportedOperation, versionNotSupported, } from './jsonrpc.ts';
15
15
  export type { JsonRpcFailure, JsonRpcRequest, JsonRpcResponse, JsonRpcSuccess } from './jsonrpc.ts';
16
- export { parsePart, parseSendParams, partsToText, renderArtifactUpdate, renderStatusUpdate, renderTask, resolveMethod, } from './normalize.ts';
17
- export type { A2AOperation } from './normalize.ts';
18
- export { buildAgentCard, FALLBACK_SKILL } from './card.ts';
16
+ export { legacyMethodReplacement, parseListTasksParams, parsePart, parseSendMessageRequest, parseTenant, partsToText, resolveMethod, } from './parse.ts';
17
+ export type { A2AOperation } from './parse.ts';
18
+ export { buildAgentCard, buildExtendedAgentCard, FALLBACK_SKILL } from './card.ts';
19
19
  export type { CardInput } from './card.ts';
20
20
  export { sseFrame } from './sse.ts';
21
- /** ISO 8601 UTC with millisecond precision, the timestamp shape A2A uses. */
21
+ /** ISO 8601 UTC with millisecond precision, the timestamp shape A2A v1.0 requires. */
22
22
  export declare function nowIso(): string;
23
23
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AACpD,YAAY,EAAE,YAAY,IAAI,gBAAgB,EAAE,SAAS,IAAI,aAAa,EAAE,MAAM,YAAY,CAAA;AAE9F,OAAO,EACL,eAAe,EACf,UAAU,GACX,MAAM,WAAW,CAAA;AAClB,YAAY,EACV,YAAY,EACZ,aAAa,EACb,WAAW,EACX,WAAW,EACX,UAAU,EACV,WAAW,EACX,UAAU,EACV,2BAA2B,EAC3B,oBAAoB,EACpB,OAAO,EACP,yBAAyB,EACzB,OAAO,EACP,cAAc,EACd,OAAO,EACP,0BAA0B,EAC1B,YAAY,EACZ,aAAa,EACb,wBAAwB,EACxB,WAAW,GACZ,MAAM,WAAW,CAAA;AAElB,OAAO,EACL,WAAW,EACX,8BAA8B,EAC9B,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,EACT,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,yBAAyB,EACzB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,cAAc,CAAA;AACrB,YAAY,EAAE,cAAc,EAAE,cAAc,EAAE,eAAe,EAAE,cAAc,EAAE,MAAM,cAAc,CAAA;AAEnG,OAAO,EACL,SAAS,EACT,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACV,aAAa,GACd,MAAM,gBAAgB,CAAA;AACvB,YAAY,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAA;AAElD,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAC1D,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,6EAA6E;AAC7E,wBAAgB,MAAM,IAAI,MAAM,CAE/B"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AA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9C,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAClF,YAAY,EAAE,SAAS,EAAE,MAAM,WAAW,CAAA;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,sFAAsF;AACtF,wBAAgB,MAAM,IAAI,MAAM,CAE/B"}
@@ -1,19 +1,19 @@
1
1
  /**
2
- * The A2A wire protocol as a dependency-free library.
2
+ * The A2A v1.0 wire protocol as a dependency-free library.
3
3
  *
4
4
  * Nothing here touches Cordis, HTTP, or the harness: it is types, framing,
5
- * dialect normalization, and document construction, so the spec's own JSON
6
- * examples can be used as golden tests without booting anything.
5
+ * inbound parsing, and document construction, so the spec's own JSON examples
6
+ * can be used as golden tests without booting anything.
7
7
  *
8
8
  * @module dsh-a2a/protocol
9
9
  */
10
10
  export { A2AContextId, A2ATaskId } from "./brand.js";
11
- export { TERMINAL_STATES, isTerminal, } from "./wire.js";
12
- export { A2ARpcError, ERR_CONTENT_TYPE_NOT_SUPPORTED, ERR_INTERNAL, ERR_INVALID_PARAMS, ERR_INVALID_REQUEST, ERR_METHOD_NOT_FOUND, ERR_PARSE, ERR_PUSH_NOT_SUPPORTED, ERR_TASK_NOT_CANCELABLE, ERR_TASK_NOT_FOUND, ERR_UNSUPPORTED_OPERATION, invalidParams, jsonRpcError, jsonRpcResult, taskNotFound, } from "./jsonrpc.js";
13
- export { parsePart, parseSendParams, partsToText, renderArtifactUpdate, renderStatusUpdate, renderTask, resolveMethod, } from "./normalize.js";
14
- export { buildAgentCard, FALLBACK_SKILL } from "./card.js";
11
+ export { A2A_PROTOCOL_VERSION, TASK_STATES, TERMINAL_STATES, isTerminal, streamArtifactUpdate, streamStatusUpdate, streamTask, } from "./wire.js";
12
+ export { A2A_ERROR_DOMAIN, A2ARpcError, ERR_CONTENT_TYPE_NOT_SUPPORTED, ERR_EXTENDED_CARD_NOT_CONFIGURED, ERR_EXTENSION_SUPPORT_REQUIRED, ERR_INTERNAL, ERR_INVALID_AGENT_RESPONSE, ERR_INVALID_PARAMS, ERR_INVALID_REQUEST, ERR_METHOD_NOT_FOUND, ERR_PARSE, ERR_PUSH_NOT_SUPPORTED, ERR_TASK_NOT_CANCELABLE, ERR_TASK_NOT_FOUND, ERR_UNSUPPORTED_OPERATION, ERR_VERSION_NOT_SUPPORTED, errorDetails, invalidParams, jsonRpcError, jsonRpcResult, taskNotFound, unsupportedOperation, versionNotSupported, } from "./jsonrpc.js";
13
+ export { legacyMethodReplacement, parseListTasksParams, parsePart, parseSendMessageRequest, parseTenant, partsToText, resolveMethod, } from "./parse.js";
14
+ export { buildAgentCard, buildExtendedAgentCard, FALLBACK_SKILL } from "./card.js";
15
15
  export { sseFrame } from "./sse.js";
16
- /** ISO 8601 UTC with millisecond precision, the timestamp shape A2A uses. */
16
+ /** ISO 8601 UTC with millisecond precision, the timestamp shape A2A v1.0 requires. */
17
17
  export function nowIso() {
18
18
  return new Date().toISOString();
19
19
  }
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAGpD,OAAO,EACL,eAAe,EACf,UAAU,GACX,MAAM,WAAW,CAAA;AAuBlB,OAAO,EACL,WAAW,EACX,8BAA8B,EAC9B,YAAY,EACZ,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,EACT,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,yBAAyB,EACzB,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,cAAc,CAAA;AAGrB,OAAO,EACL,SAAS,EACT,eAAe,EACf,WAAW,EACX,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACV,aAAa,GACd,MAAM,gBAAgB,CAAA;AAGvB,OAAO,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAG1D,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,6EAA6E;AAC7E,MAAM,UAAU,MAAM;IACpB,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;AACjC,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/protocol/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,YAAY,CAAA;AAGpD,OAAO,EACL,oBAAoB,EACpB,WAAW,EACX,eAAe,EACf,UAAU,EACV,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,GACX,MAAM,WAAW,CAAA;AA6BlB,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,8BAA8B,EAC9B,gCAAgC,EAChC,8BAA8B,EAC9B,YAAY,EACZ,0BAA0B,EAC1B,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,EACT,sBAAsB,EACtB,uBAAuB,EACvB,kBAAkB,EAClB,yBAAyB,EACzB,yBAAyB,EACzB,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,cAAc,CAAA;AAGrB,OAAO,EACL,uBAAuB,EACvB,oBAAoB,EACpB,SAAS,EACT,uBAAuB,EACvB,WAAW,EACX,WAAW,EACX,aAAa,GACd,MAAM,YAAY,CAAA;AAGnB,OAAO,EAAE,cAAc,EAAE,sBAAsB,EAAE,cAAc,EAAE,MAAM,WAAW,CAAA;AAGlF,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAA;AAEnC,sFAAsF;AACtF,MAAM,UAAU,MAAM;IACpB,OAAO,IAAI,IAAI,EAAE,CAAC,WAAW,EAAE,CAAA;AACjC,CAAC"}
@@ -8,6 +8,10 @@
8
8
  * a valid JSON-RPC error envelope, so a client that blindly parses the body
9
9
  * and one that reads the status are both served.
10
10
  *
11
+ * v1.0 additionally requires that A2A-specific failures carry a machine-
12
+ * readable reason in `error.data`, as a `google.rpc.ErrorInfo` object. That is
13
+ * what {@link A2ARpcError.reason} feeds.
14
+ *
11
15
  * @module dsh-a2a/protocol/jsonrpc
12
16
  */
13
17
  /** Standard JSON-RPC 2.0 codes. */
@@ -22,6 +26,12 @@ export declare const ERR_TASK_NOT_CANCELABLE = -32002;
22
26
  export declare const ERR_PUSH_NOT_SUPPORTED = -32003;
23
27
  export declare const ERR_UNSUPPORTED_OPERATION = -32004;
24
28
  export declare const ERR_CONTENT_TYPE_NOT_SUPPORTED = -32005;
29
+ export declare const ERR_INVALID_AGENT_RESPONSE = -32006;
30
+ export declare const ERR_EXTENDED_CARD_NOT_CONFIGURED = -32007;
31
+ export declare const ERR_EXTENSION_SUPPORT_REQUIRED = -32008;
32
+ export declare const ERR_VERSION_NOT_SUPPORTED = -32009;
33
+ /** The domain every A2A `ErrorInfo` detail is scoped to. */
34
+ export declare const A2A_ERROR_DOMAIN = "a2a-protocol.org";
25
35
  /** A JSON-RPC request as received from a peer. */
26
36
  export interface JsonRpcRequest {
27
37
  jsonrpc?: string;
@@ -59,21 +69,46 @@ export declare function jsonRpcResult(id: string | number | null, result: unknow
59
69
  * @param id - the request id being answered, or null when unknown.
60
70
  * @param code - the JSON-RPC or A2A error code.
61
71
  * @param message - a human-readable explanation carrying no internal paths.
62
- * @param data - optional structured detail.
72
+ * @param data - optional structured detail, already in the details-array shape.
63
73
  * @returns the response envelope.
64
74
  */
65
75
  export declare function jsonRpcError(id: string | number | null, code: number, message: string, data?: unknown): JsonRpcFailure;
66
- /** An error carrying the JSON-RPC code a handler wants reported. */
76
+ /**
77
+ * Build the `error.data` details array for an A2A-specific failure.
78
+ *
79
+ * v1.0 models error details on `google.rpc.Status`: an array of typed objects,
80
+ * each naming its type through `@type`. The reason is the UPPER_SNAKE_CASE form
81
+ * of the A2A error name, which is what lets a client branch on the failure
82
+ * without string-matching the human-readable message.
83
+ * @param reason - the A2A error reason, e.g. `TASK_NOT_FOUND`.
84
+ * @param metadata - additional string context, e.g. the offending id.
85
+ * @returns the details array.
86
+ */
87
+ export declare function errorDetails(reason: string, metadata?: Record<string, string>): unknown[];
88
+ /** An error carrying the JSON-RPC code and A2A reason a handler wants reported. */
67
89
  export declare class A2ARpcError extends Error {
68
90
  readonly code: number;
69
- readonly httpStatus: number;
91
+ readonly options: {
92
+ reason?: string;
93
+ metadata?: Record<string, string>;
94
+ httpStatus?: number;
95
+ };
70
96
  /**
71
97
  * @param code - the JSON-RPC or A2A error code.
72
98
  * @param message - the human-readable explanation.
73
- * @param httpStatus - the HTTP status to answer with; defaults to 200 because
74
- * an ordinary JSON-RPC error is a successful HTTP exchange.
99
+ * @param options - the A2A reason and metadata for `error.data`, plus the
100
+ * HTTP status to answer with; the status defaults to 200 because an ordinary
101
+ * JSON-RPC error is a successful HTTP exchange.
75
102
  */
76
- constructor(code: number, message: string, httpStatus?: number);
103
+ constructor(code: number, message: string, options?: {
104
+ reason?: string;
105
+ metadata?: Record<string, string>;
106
+ httpStatus?: number;
107
+ });
108
+ /** The HTTP status this failure should be answered with. */
109
+ get httpStatus(): number;
110
+ /** The `error.data` details array, or undefined when no reason is carried. */
111
+ get data(): unknown[] | undefined;
77
112
  }
78
113
  /**
79
114
  * Reject a malformed or unsupported parameter.
@@ -90,4 +125,17 @@ export declare function invalidParams(detail: string): A2ARpcError;
90
125
  * @returns the error to throw.
91
126
  */
92
127
  export declare function taskNotFound(taskId: string): A2ARpcError;
128
+ /**
129
+ * Report an A2A-Version this interface does not implement.
130
+ * @param requested - the version the peer asked for.
131
+ * @param supported - the version this interface serves.
132
+ * @returns the error to throw.
133
+ */
134
+ export declare function versionNotSupported(requested: string, supported: string): A2ARpcError;
135
+ /**
136
+ * Report an operation this deployment does not perform.
137
+ * @param detail - what was refused, and why.
138
+ * @returns the error to throw.
139
+ */
140
+ export declare function unsupportedOperation(detail: string): A2ARpcError;
93
141
  //# sourceMapp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;;;;;;;;;;GAUG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,MAAM,EACd,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAChC,OAAO,EAAE,CAOX;AAED,mFAAmF;AACnF,qBAAa,WAAY,SAAQ,KAAK;IASlC,QAAQ,CAAC,IAAI,EAAE,MAAM;IAErB,QAAQ,CAAC,OAAO,EAAE;QAChB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACjC,UAAU,CAAC,EAAE,MAAM,CAAA;KACpB;IAdH;;;;;;OAMG;gBAEQ,IAAI,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACN,OAAO,GAAE;QAChB,MAAM,CAAC,EAAE,MAAM,CAAA;QACf,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QACjC,UAAU,CAAC,EAAE,MAAM,CAAA;KACf;IAMR,4DAA4D;IAC5D,IAAI,UAAU,IAAI,MAAM,CAEvB;IAED,8EAA8E;IAC9E,IAAI,IAAI,IAAI,OAAO,EAAE,GAAG,SAAS,CAGhC;CACF;AAED;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAEzD;AAED;;;;;;;GAOG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAKxD;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,SAAS,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,GAAG,WAAW,CAMrF;AAED;;;;GAIG;AACH,wBAAgB,oBAAoB,CAAC,MAAM,EAAE,MAAM,GAAG,WAAW,CAIhE"}
@@ -8,6 +8,10 @@
8
8
  * a valid JSON-RPC error envelope, so a client that blindly parses the body
9
9
  * and one that reads the status are both served.
10
10
  *
11
+ * v1.0 additionally requires that A2A-specific failures carry a machine-
12
+ * readable reason in `error.data`, as a `google.rpc.ErrorInfo` object. That is
13
+ * what {@link A2ARpcError.reason} feeds.
14
+ *
11
15
  * @module dsh-a2a/protocol/jsonrpc
12
16
  */
13
17
  /** Standard JSON-RPC 2.0 codes. */
@@ -22,6 +26,12 @@ export const ERR_TASK_NOT_CANCELABLE = -32002;
22
26
  export const ERR_PUSH_NOT_SUPPORTED = -32003;
23
27
  export const ERR_UNSUPPORTED_OPERATION = -32004;
24
28
  export const ERR_CONTENT_TYPE_NOT_SUPPORTED = -32005;
29
+ export const ERR_INVALID_AGENT_RESPONSE = -32006;
30
+ export const ERR_EXTENDED_CARD_NOT_CONFIGURED = -32007;
31
+ export const ERR_EXTENSION_SUPPORT_REQUIRED = -32008;
32
+ export const ERR_VERSION_NOT_SUPPORTED = -32009;
33
+ /** The domain every A2A `ErrorInfo` detail is scoped to. */
34
+ export const A2A_ERROR_DOMAIN = 'a2a-protocol.org';
25
35
  /**
26
36
  * Build a success envelope.
27
37
  * @param id - the request id being answered.
@@ -36,28 +46,58 @@ export function jsonRpcResult(id, result) {
36
46
  * @param id - the request id being answered, or null when unknown.
37
47
  * @param code - the JSON-RPC or A2A error code.
38
48
  * @param message - a human-readable explanation carrying no internal paths.
39
- * @param data - optional structured detail.
49
+ * @param data - optional structured detail, already in the details-array shape.
40
50
  * @returns the response envelope.
41
51
  */
42
52
  export function jsonRpcError(id, code, message, data) {
43
53
  return { jsonrpc: '2.0', id, error: { code, message, ...data === undefined ? {} : { data } } };
44
54
  }
45
- /** An error carrying the JSON-RPC code a handler wants reported. */
55
+ /**
56
+ * Build the `error.data` details array for an A2A-specific failure.
57
+ *
58
+ * v1.0 models error details on `google.rpc.Status`: an array of typed objects,
59
+ * each naming its type through `@type`. The reason is the UPPER_SNAKE_CASE form
60
+ * of the A2A error name, which is what lets a client branch on the failure
61
+ * without string-matching the human-readable message.
62
+ * @param reason - the A2A error reason, e.g. `TASK_NOT_FOUND`.
63
+ * @param metadata - additional string context, e.g. the offending id.
64
+ * @returns the details array.
65
+ */
66
+ export function errorDetails(reason, metadata) {
67
+ return [{
68
+ '@type': 'type.googleapis.com/google.rpc.ErrorInfo',
69
+ reason,
70
+ domain: A2A_ERROR_DOMAIN,
71
+ ...metadata === undefined ? {} : { metadata },
72
+ }];
73
+ }
74
+ /** An error carrying the JSON-RPC code and A2A reason a handler wants reported. */
46
75
  export class A2ARpcError extends Error {
47
76
  code;
48
- httpStatus;
77
+ options;
49
78
  /**
50
79
  * @param code - the JSON-RPC or A2A error code.
51
80
  * @param message - the human-readable explanation.
52
- * @param httpStatus - the HTTP status to answer with; defaults to 200 because
53
- * an ordinary JSON-RPC error is a successful HTTP exchange.
81
+ * @param options - the A2A reason and metadata for `error.data`, plus the
82
+ * HTTP status to answer with; the status defaults to 200 because an ordinary
83
+ * JSON-RPC error is a successful HTTP exchange.
54
84
  */
55
- constructor(code, message, httpStatus = 200) {
85
+ constructor(code, message, options = {}) {
56
86
  super(message);
57
87
  this.code = code;
58
- this.httpStatus = httpStatus;
88
+ this.options = options;
59
89
  this.name = 'A2ARpcError';
60
90
  }
91
+ /** The HTTP status this failure should be answered with. */
92
+ get httpStatus() {
93
+ return this.options.httpStatus ?? 200;
94
+ }
95
+ /** The `error.data` details array, or undefined when no reason is carried. */
96
+ get data() {
97
+ if (this.options.reason === undefined)
98
+ return undefined;
99
+ return errorDetails(this.options.reason, this.options.metadata);
100
+ }
61
101
  }
62
102
  /**
63
103
  * Reject a malformed or unsupported parameter.
@@ -76,6 +116,28 @@ export function invalidParams(detail) {
76
116
  * @returns the error to throw.
77
117
  */
78
118
  export function taskNotFound(taskId) {
79
- return new A2ARpcError(ERR_TASK_NOT_FOUND, `task not found: ${taskId}`);
119
+ return new A2ARpcError(ERR_TASK_NOT_FOUND, `task not found: ${taskId}`, {
120
+ reason: 'TASK_NOT_FOUND',
121
+ metadata: { taskId },
122
+ });
123
+ }
124
+ /**
125
+ * Report an A2A-Version this interface does not implement.
126
+ * @param requested - the version the peer asked for.
127
+ * @param supported - the version this interface serves.
128
+ * @returns the error to throw.
129
+ */
130
+ export function versionNotSupported(requested, supported) {
131
+ return new A2ARpcError(ERR_VERSION_NOT_SUPPORTED, `unsupported A2A-Version: ${requested}; this interface serves ${supported}`, { reason: 'VERSION_NOT_SUPPORTED', metadata: { requested, supported } });
132
+ }
133
+ /**
134
+ * Report an operation this deployment does not perform.
135
+ * @param detail - what was refused, and why.
136
+ * @returns the error to throw.
137
+ */
138
+ export function unsupportedOperation(detail) {
139
+ return new A2ARpcError(ERR_UNSUPPORTED_OPERATION, detail, {
140
+ reason: 'UNSUPPORTED_OPERATION',
141
+ });
80
142
  }
81
143
  //# sourceMappingURL=jsonrpc.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"jsonrpc.js","sourceRoot":"","sources":["../../src/protocol/jsonrpc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH,mCAAmC;AACnC,MAAM,CAAC,MAAM,SAAS,GAAG,CAAC,KAAK,CAAA;AAC/B,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,KAAK,CAAA;AACzC,MAAM,CAAC,MAAM,oBAAoB,GAAG,CAAC,KAAK,CAAA;AAC1C,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAK,CAAA;AACxC,MAAM,CAAC,MAAM,YAAY,GAAG,CAAC,KAAK,CAAA;AAElC,+DAA+D;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,KAAK,CAAA;AACxC,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,KAAK,CAAA;AAC7C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAK,CAAA;AAC5C,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,KAAK,CAAA;AAC/C,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,KAAK,CAAA;AA2BpD;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,EAA0B,EAAE,MAAe;IACvE,OAAO,EAA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AI,WAAW,CACpB,yBAAyB,EACzB,4BAA4B,SAAS,2BAA2B,SAAS,EAAE,EAC3E,EAAE,MAAM,EAAE,uBAAuB,EAAE,QAAQ,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,EAAE,CACxE,CAAA;AACH,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,oBAAoB,CAAC,MAAc;IACjD,OAAO,IAAI,WAAW,CAAC,yBAAyB,EAAE,MAAM,EAAE;QACxD,MAAM,EAAE,uBAAuB;KAChC,CAAC,CAAA;AACJ,CAAC"}
@@ -0,0 +1,79 @@
1
+ /**
2
+ * Inbound parsing: peer JSON to the internal v1.0 shape.
3
+ *
4
+ * There is no outbound counterpart. v0.3 needed one because two spellings had
5
+ * to be reconciled; this server speaks v1.0 only, so what {@link ./wire.ts}
6
+ * describes is what gets serialized, and the only work left is validating what
7
+ * arrives.
8
+ *
9
+ * Parsing is permissive about what it IGNORES (unknown members are skipped, as
10
+ * the spec's forward-compatibility rule requires) and strict about what it
11
+ * ACCEPTS: a v0.3 spelling is not quietly translated, because a peer that
12
+ * believes it is talking v0.3 to a v1.0-only agent needs to be told.
13
+ *
14
+ * @module dsh-a2a/protocol/parse
15
+ */
16
+ import type { A2AListTasksParams, A2APart, A2ASendMessageRequest } from './wire.ts';
17
+ /** The internal operation a peer's method name resolves to. */
18
+ export type A2AOperation = 'send' | 'stream' | 'get' | 'list' | 'cancel' | 'subscribe' | 'push_create' | 'push_get' | 'push_list' | 'push_delete' | 'extended_card';
19
+ /**
20
+ * Resolve a method name to its operation.
21
+ * @param method - the raw `method` string from the request.
22
+ * @returns the operation, or undefined for an unknown method.
23
+ */
24
+ export declare function resolveMethod(method: string): A2AOperation | undefined;
25
+ /**
26
+ * The v1.0 name that replaced a retired v0.3 method.
27
+ * @param method - the raw `method` string from the request.
28
+ * @returns the replacement name, or undefined when the method was never ours.
29
+ */
30
+ export declare function legacyMethodReplacement(method: string): string | undefined;
31
+ /**
32
+ * Read one `Part`.
33
+ *
34
+ * v1.0 discriminates on which content member is present, so the probes below
35
+ * must each be specific enough not to claim another variant's shape. An
36
+ * unrecognizable part yields undefined rather than throwing: one odd part must
37
+ * not fail a request whose other parts are usable.
38
+ * @param raw - one element of a `parts` array.
39
+ * @returns the normalized part, or undefined when no content member is present.
40
+ */
41
+ export declare function parsePart(raw: unknown): A2APart | undefined;
42
+ /**
43
+ * Render every part as text the model can read.
44
+ *
45
+ * File and data parts become bracketed references rather than being dropped, so
46
+ * the agent knows something was attached and can ask about it. This is the same
47
+ * flattening `dsh-acp` applies to baseline resource links.
48
+ * @param parts - normalized parts, in order.
49
+ * @returns the joined text, empty when nothing rendered.
50
+ */
51
+ export declare function partsToText(parts: readonly A2APart[]): string;
52
+ /**
53
+ * Parse the `SendMessage` / `SendStreamingMessage` request object.
54
+ * @param raw - the request's `params` value.
55
+ * @returns the normalized request, or undefined when the shape is unusable.
56
+ */
57
+ export declare function parseSendMessageRequest(raw: unknown): A2ASendMessageRequest | undefined;
58
+ /**
59
+ * Parse `ListTasks` parameters.
60
+ *
61
+ * Every filter is optional; an absent `params` lists everything the caller may
62
+ * see. `pageSize` is clamped to the spec's 1..100 window rather than rejected,
63
+ * because a client asking for 500 wants "as many as you'll give me".
64
+ * @param raw - the request's `params` value.
65
+ * @returns the normalized filters.
66
+ */
67
+ export declare function parseListTasksParams(raw: unknown): A2AListTasksParams;
68
+ /**
69
+ * Read the `tenant` routing member.
70
+ *
71
+ * This card declares no tenant on its interface, so the spec's rule ("clients
72
+ * MUST include this value ... omit the field if tenant is not set") makes any
73
+ * non-empty tenant a misrouted request. Reporting it beats silently serving a
74
+ * peer that believes it reached a different agent.
75
+ * @param raw - the request's `params` value.
76
+ * @returns the tenant a peer asked for, or undefined when correctly omitted.
77
+ */
78
+ export declare function parseTenant(raw: unknown): string | undefined;
79
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/protocol/parse.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAIH,OAAO,KAAK,EACV,kBAAkB,EAElB,OAAO,EAEP,qBAAqB,EAEtB,MAAM,WAAW,CAAA;AAElB,+DAA+D;AAC/D,MAAM,MAAM,YAAY,GACpB,MAAM,GACN,QAAQ,GACR,KAAK,GACL,MAAM,GACN,QAAQ,GACR,WAAW,GACX,aAAa,GACb,UAAU,GACV,WAAW,GACX,aAAa,GACb,eAAe,CAAA;AA4CnB;;;;GAIG;AACH,wBAAgB,aAAa,CAAC,MAAM,EAAE,MAAM,GAAG,YAAY,GAAG,SAAS,CAEtE;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE1E;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,GAAG,SAAS,CAmB3D;AAED;;;;;;;;GAQG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,SAAS,OAAO,EAAE,GAAG,MAAM,CAc7D;AAED;;;;GAIG;AACH,wBAAgB,uBAAuB,CAAC,GAAG,EAAE,OAAO,GAAG,qBAAqB,GAAG,SAAS,CAqCvF;AAED;;;;;;;;GAQG;AACH,wBAAgB,oBAAoB,CAAC,GAAG,EAAE,OAAO,GAAG,kBAAkB,CA4BrE;AAED;;;;;;;;;GASG;AACH,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAG5D"}