@pulsarinteractive/geniustasker 0.1.0-beta.13 → 0.1.0-beta.14

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.
@@ -0,0 +1,121 @@
1
+ // Generated public task availability schema. Do not edit by hand.
2
+ export default {
3
+ "type": "object",
4
+ "required": [
5
+ "blockersTruncated",
6
+ "blockingIds",
7
+ "dependencyCount",
8
+ "incomplete",
9
+ "manualReason",
10
+ "progress",
11
+ "source",
12
+ "status"
13
+ ],
14
+ "properties": {
15
+ "blockersTruncated": {
16
+ "type": "boolean"
17
+ },
18
+ "blockingIds": {
19
+ "type": "array",
20
+ "maxItems": 20,
21
+ "items": {
22
+ "type": "string"
23
+ }
24
+ },
25
+ "dependencyCount": {
26
+ "type": "integer",
27
+ "minimum": 0,
28
+ "maximum": 1000
29
+ },
30
+ "incomplete": {
31
+ "type": "boolean"
32
+ },
33
+ "manualReason": {
34
+ "anyOf": [
35
+ {
36
+ "type": "string"
37
+ },
38
+ {
39
+ "type": "null"
40
+ }
41
+ ]
42
+ },
43
+ "progress": {
44
+ "oneOf": [
45
+ {
46
+ "type": "string",
47
+ "enum": [
48
+ "New"
49
+ ]
50
+ },
51
+ {
52
+ "type": "string",
53
+ "enum": [
54
+ "InProgress"
55
+ ]
56
+ },
57
+ {
58
+ "type": "string",
59
+ "enum": [
60
+ "Done"
61
+ ]
62
+ }
63
+ ]
64
+ },
65
+ "source": {
66
+ "type": "object",
67
+ "required": [
68
+ "authorizationEpoch",
69
+ "epoch",
70
+ "head"
71
+ ],
72
+ "properties": {
73
+ "authorizationEpoch": {
74
+ "type": "string"
75
+ },
76
+ "epoch": {
77
+ "type": "string"
78
+ },
79
+ "head": {
80
+ "type": "string"
81
+ }
82
+ },
83
+ "additionalProperties": false
84
+ },
85
+ "status": {
86
+ "oneOf": [
87
+ {
88
+ "type": "string",
89
+ "enum": [
90
+ "New"
91
+ ]
92
+ },
93
+ {
94
+ "type": "string",
95
+ "enum": [
96
+ "InProgress"
97
+ ]
98
+ },
99
+ {
100
+ "type": "string",
101
+ "enum": [
102
+ "Done"
103
+ ]
104
+ },
105
+ {
106
+ "type": "string",
107
+ "enum": [
108
+ "Locked"
109
+ ]
110
+ },
111
+ {
112
+ "type": "string",
113
+ "enum": [
114
+ "Unknown"
115
+ ]
116
+ }
117
+ ]
118
+ }
119
+ },
120
+ "additionalProperties": false
121
+ };
@@ -0,0 +1,25 @@
1
+ import * as z from 'zod/v4';
2
+ import contract from './task-availability-contract.mjs';
3
+
4
+ export const taskAvailabilitySchema = z.fromJSONSchema(contract);
5
+
6
+ /** Validate only the optional projection. Its head belongs to the current task
7
+ * module, not necessarily the page's historical checkpoint or the row revision.
8
+ * Legacy absence is retained; it must never become an invented unlocked state. */
9
+ export function validTaskAvailabilityPage(page, collection, taskState) {
10
+ if (!Array.isArray(page?.items)) {
11
+ return true;
12
+ }
13
+ return page.items.every((item) => {
14
+ if (!item || !Object.hasOwn(item, 'taskAvailability')) {
15
+ return true;
16
+ }
17
+ return (
18
+ collection === 'tasks' &&
19
+ taskState === 'v1' &&
20
+ item.kind !== 'remove' &&
21
+ taskAvailabilitySchema.safeParse(item.taskAvailability).success &&
22
+ item.taskAvailability.source.epoch === page.epoch
23
+ );
24
+ });
25
+ }
package/src/transport.mjs CHANGED
@@ -80,10 +80,17 @@ export class Transport {
80
80
  }
81
81
  }
82
82
  }
83
+ const feedbackMedia =
84
+ /^\/api\/agents\/v1\/feedback\/media\/[a-f0-9]{8}-(?:[a-f0-9]{4}-){3}[a-f0-9]{12}\/content$/.test(
85
+ url.pathname,
86
+ );
83
87
  if (
84
88
  (bytes !== undefined || binary) &&
85
- (url.pathname !== '/api/agents/v1/media/content' ||
86
- (bytes !== undefined && (!Buffer.isBuffer(bytes) || bytes.length > 15000000)) ||
89
+ ((!feedbackMedia && url.pathname !== '/api/agents/v1/media/content') ||
90
+ (feedbackMedia &&
91
+ (url.search || (bytes !== undefined ? method !== 'PUT' : method !== 'GET'))) ||
92
+ (bytes !== undefined &&
93
+ (!Buffer.isBuffer(bytes) || bytes.length > (feedbackMedia ? 4_000_000 : 15_000_000))) ||
87
94
  (bytes !== undefined && (json !== undefined || form)))
88
95
  ) {
89
96
  fail('invalid_arguments', 'Binary transfer requires the bounded delegated media endpoint.');
@@ -144,7 +151,7 @@ export class Transport {
144
151
  if (response.body) {
145
152
  for await (const chunk of response.body) {
146
153
  size += chunk.length;
147
- if (size > (binary && response.ok ? 15000000 : 262144)) {
154
+ if (size > (binary && response.ok ? (feedbackMedia ? 1_000_000 : 15_000_000) : 262144)) {
148
155
  fail('invalid_response', 'The API response exceeded the size limit.');
149
156
  }
150
157
  chunks.push(chunk);