@tasqmate/sdk 0.0.0-stage → 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/LICENSE +21 -0
- package/README.md +58 -2
- package/dist/index.d.ts +6319 -0
- package/dist/index.js +866 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -5
package/dist/index.js
ADDED
|
@@ -0,0 +1,866 @@
|
|
|
1
|
+
// src/prefixes.ts
|
|
2
|
+
var AGENT_KEY_PREFIX = "tq_ag_";
|
|
3
|
+
var USER_TOKEN_PREFIX = "tq_us_";
|
|
4
|
+
|
|
5
|
+
// src/files.ts
|
|
6
|
+
var TYPES = new Map(Object.entries({
|
|
7
|
+
avif: "image/avif",
|
|
8
|
+
csv: "text/csv",
|
|
9
|
+
doc: "application/msword",
|
|
10
|
+
docx: "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
|
11
|
+
gif: "image/gif",
|
|
12
|
+
gz: "application/gzip",
|
|
13
|
+
heic: "image/heic",
|
|
14
|
+
htm: "text/html",
|
|
15
|
+
html: "text/html",
|
|
16
|
+
jpeg: "image/jpeg",
|
|
17
|
+
jpg: "image/jpeg",
|
|
18
|
+
json: "application/json",
|
|
19
|
+
key: "application/vnd.apple.keynote",
|
|
20
|
+
log: "text/plain",
|
|
21
|
+
md: "text/markdown",
|
|
22
|
+
mov: "video/quicktime",
|
|
23
|
+
mp3: "audio/mpeg",
|
|
24
|
+
mp4: "video/mp4",
|
|
25
|
+
pdf: "application/pdf",
|
|
26
|
+
png: "image/png",
|
|
27
|
+
ppt: "application/vnd.ms-powerpoint",
|
|
28
|
+
pptx: "application/vnd.openxmlformats-officedocument.presentationml.presentation",
|
|
29
|
+
svg: "image/svg+xml",
|
|
30
|
+
tar: "application/x-tar",
|
|
31
|
+
tsv: "text/tab-separated-values",
|
|
32
|
+
txt: "text/plain",
|
|
33
|
+
wav: "audio/wav",
|
|
34
|
+
webm: "video/webm",
|
|
35
|
+
webp: "image/webp",
|
|
36
|
+
xls: "application/vnd.ms-excel",
|
|
37
|
+
xlsx: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
|
|
38
|
+
yaml: "application/yaml",
|
|
39
|
+
yml: "application/yaml",
|
|
40
|
+
zip: "application/zip"
|
|
41
|
+
}));
|
|
42
|
+
function contentTypeFor(fileName) {
|
|
43
|
+
const dot = fileName.lastIndexOf(".");
|
|
44
|
+
const extension = dot === -1 ? "" : fileName.slice(dot + 1).toLowerCase();
|
|
45
|
+
return TYPES.get(extension) ?? "application/octet-stream";
|
|
46
|
+
}
|
|
47
|
+
function formatFileSize(bytes) {
|
|
48
|
+
if (bytes < 1024) return `${bytes} B`;
|
|
49
|
+
const units = ["KB", "MB", "GB"];
|
|
50
|
+
let value = bytes / 1024;
|
|
51
|
+
let unit = 0;
|
|
52
|
+
while (value >= 1024 && unit < units.length - 1) {
|
|
53
|
+
value /= 1024;
|
|
54
|
+
unit += 1;
|
|
55
|
+
}
|
|
56
|
+
const rounded = value >= 10 ? Math.round(value) : Math.round(value * 10) / 10;
|
|
57
|
+
return `${rounded} ${units[unit]}`;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// src/errors.ts
|
|
61
|
+
var TasqmateApiError = class extends Error {
|
|
62
|
+
code;
|
|
63
|
+
status;
|
|
64
|
+
details;
|
|
65
|
+
constructor(status, body) {
|
|
66
|
+
super(body.message);
|
|
67
|
+
this.name = "TasqmateApiError";
|
|
68
|
+
this.code = body.code;
|
|
69
|
+
this.status = status;
|
|
70
|
+
this.details = body.details;
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
var TasqmateRateLimitError = class extends TasqmateApiError {
|
|
74
|
+
retryAfterSeconds;
|
|
75
|
+
resetAt;
|
|
76
|
+
limit;
|
|
77
|
+
remaining;
|
|
78
|
+
constructor(status, body, retryAfterHeader) {
|
|
79
|
+
super(status, body);
|
|
80
|
+
this.name = "TasqmateRateLimitError";
|
|
81
|
+
const details = body.details ?? {};
|
|
82
|
+
this.limit = details.limit;
|
|
83
|
+
this.remaining = details.remaining;
|
|
84
|
+
this.resetAt = details.resetAt === void 0 ? void 0 : new Date(details.resetAt);
|
|
85
|
+
const fromHeader = Number(retryAfterHeader);
|
|
86
|
+
if (retryAfterHeader !== null && Number.isFinite(fromHeader)) {
|
|
87
|
+
this.retryAfterSeconds = Math.max(0, fromHeader);
|
|
88
|
+
} else if (this.resetAt !== void 0) {
|
|
89
|
+
const ms = this.resetAt.getTime() - Date.now();
|
|
90
|
+
this.retryAfterSeconds = Math.max(0, Math.ceil(ms / 1e3));
|
|
91
|
+
} else {
|
|
92
|
+
this.retryAfterSeconds = 0;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
var TasqmateValidationError = class extends TasqmateApiError {
|
|
97
|
+
issues;
|
|
98
|
+
constructor(status, body) {
|
|
99
|
+
super(status, body);
|
|
100
|
+
this.name = "TasqmateValidationError";
|
|
101
|
+
this.issues = Array.isArray(body.details) ? body.details : [];
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
var TasqmatePolicyDeniedError = class extends TasqmateApiError {
|
|
105
|
+
/** The rejected action name, when the API reported one. */
|
|
106
|
+
action;
|
|
107
|
+
/** The policy version quoted in the message, when the API quoted one. */
|
|
108
|
+
policyVersion;
|
|
109
|
+
constructor(status, body) {
|
|
110
|
+
super(status, body);
|
|
111
|
+
this.name = "TasqmatePolicyDeniedError";
|
|
112
|
+
this.action = actionFromDetails(body.details);
|
|
113
|
+
this.policyVersion = policyVersionFromMessage(body.message);
|
|
114
|
+
}
|
|
115
|
+
};
|
|
116
|
+
function actionFromDetails(details) {
|
|
117
|
+
if (!Array.isArray(details)) return void 0;
|
|
118
|
+
const issues = details;
|
|
119
|
+
for (const issue of issues) {
|
|
120
|
+
if (issue.path[0] === "action") return issue.message;
|
|
121
|
+
}
|
|
122
|
+
return void 0;
|
|
123
|
+
}
|
|
124
|
+
function policyVersionFromMessage(message) {
|
|
125
|
+
const match = /policy v(?:ersion )?(\d+)/i.exec(message);
|
|
126
|
+
if (!match?.[1]) return void 0;
|
|
127
|
+
return Number(match[1]);
|
|
128
|
+
}
|
|
129
|
+
function noCredentialError() {
|
|
130
|
+
return new TasqmateApiError(0, {
|
|
131
|
+
code: "NO_CREDENTIAL",
|
|
132
|
+
message: "No credential configured. Run `tasqmate auth login`, or set TASQMATE_API_KEY."
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
function toTasqmateError(status, body, retryAfterHeader) {
|
|
136
|
+
if (status === 429 || body.code === "RATE_LIMITED") {
|
|
137
|
+
return new TasqmateRateLimitError(status, body, retryAfterHeader);
|
|
138
|
+
}
|
|
139
|
+
if (body.code === "VALIDATION_ERROR") {
|
|
140
|
+
return new TasqmateValidationError(status, body);
|
|
141
|
+
}
|
|
142
|
+
if (body.code === "AGENT_ACTION_DENIED") {
|
|
143
|
+
return new TasqmatePolicyDeniedError(status, body);
|
|
144
|
+
}
|
|
145
|
+
return new TasqmateApiError(status, body);
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
// src/client.ts
|
|
149
|
+
var PROJECT_UPDATES_PAGE_MAX = 100;
|
|
150
|
+
function assertPrefix(token, prefix, label) {
|
|
151
|
+
if (!token.startsWith(prefix)) {
|
|
152
|
+
throw new Error(
|
|
153
|
+
`Invalid ${label}: expected a token starting with "${prefix}".`
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
function credential(auth) {
|
|
158
|
+
if (auth === void 0) return void 0;
|
|
159
|
+
if ("agentKey" in auth) {
|
|
160
|
+
assertPrefix(auth.agentKey, AGENT_KEY_PREFIX, "agent key");
|
|
161
|
+
return auth.agentKey;
|
|
162
|
+
}
|
|
163
|
+
assertPrefix(auth.userToken, USER_TOKEN_PREFIX, "user token");
|
|
164
|
+
return auth.userToken;
|
|
165
|
+
}
|
|
166
|
+
function normaliseBaseUrl(baseUrl) {
|
|
167
|
+
return `${baseUrl.replace(/\/+$/, "")}/api`;
|
|
168
|
+
}
|
|
169
|
+
function queryString(params) {
|
|
170
|
+
if (!params) return "";
|
|
171
|
+
const search = new URLSearchParams();
|
|
172
|
+
for (const [key, value] of Object.entries(params)) {
|
|
173
|
+
if (value === void 0) continue;
|
|
174
|
+
search.set(key, String(value));
|
|
175
|
+
}
|
|
176
|
+
const encoded = search.toString();
|
|
177
|
+
return encoded === "" ? "" : `?${encoded}`;
|
|
178
|
+
}
|
|
179
|
+
var TasqmateClient = class _TasqmateClient {
|
|
180
|
+
#baseUrl;
|
|
181
|
+
#token;
|
|
182
|
+
#fetch;
|
|
183
|
+
/** A client with no credential, for the two anonymous auth calls. */
|
|
184
|
+
static anonymous(baseUrl, fetchImpl) {
|
|
185
|
+
return new _TasqmateClient({ baseUrl, fetch: fetchImpl });
|
|
186
|
+
}
|
|
187
|
+
constructor(options) {
|
|
188
|
+
this.#baseUrl = normaliseBaseUrl(options.baseUrl);
|
|
189
|
+
this.#token = credential(options.auth);
|
|
190
|
+
this.#fetch = options.fetch ?? globalThis.fetch;
|
|
191
|
+
}
|
|
192
|
+
async #request(path, init = {}) {
|
|
193
|
+
const { anonymous = false, timeoutMs, ...requestInit } = init;
|
|
194
|
+
const headers = new Headers(requestInit.headers);
|
|
195
|
+
if (!anonymous) {
|
|
196
|
+
if (this.#token === void 0) throw noCredentialError();
|
|
197
|
+
headers.set("authorization", `Bearer ${this.#token}`);
|
|
198
|
+
}
|
|
199
|
+
if (requestInit.body !== void 0 && !headers.has("content-type")) {
|
|
200
|
+
headers.set("content-type", "application/json");
|
|
201
|
+
}
|
|
202
|
+
headers.set("accept", "application/json");
|
|
203
|
+
const timeout = timeoutMs === void 0 ? void 0 : AbortSignal.timeout(timeoutMs);
|
|
204
|
+
const signals = [requestInit.signal, timeout].filter(
|
|
205
|
+
(candidate) => candidate != null
|
|
206
|
+
);
|
|
207
|
+
const signal = signals.length === 0 ? void 0 : signals.length === 1 ? signals[0] : AbortSignal.any(signals);
|
|
208
|
+
const response = await this.#fetch(`${this.#baseUrl}${path}`, {
|
|
209
|
+
...requestInit,
|
|
210
|
+
headers,
|
|
211
|
+
signal
|
|
212
|
+
});
|
|
213
|
+
if (!response.ok) {
|
|
214
|
+
throw await this.#toError(response);
|
|
215
|
+
}
|
|
216
|
+
return await response.json();
|
|
217
|
+
}
|
|
218
|
+
/**
|
|
219
|
+
* A read whose body is Markdown rather than JSON.
|
|
220
|
+
*
|
|
221
|
+
* The export and the `format=markdown` context are documents, not
|
|
222
|
+
* envelopes, so they are read as text. Errors still arrive as the JSON
|
|
223
|
+
* envelope every other route uses, so the failure path is `#toError`'s,
|
|
224
|
+
* unchanged.
|
|
225
|
+
*/
|
|
226
|
+
async #text(path, params, options) {
|
|
227
|
+
const headers = new Headers({ accept: "text/markdown" });
|
|
228
|
+
if (this.#token === void 0) throw noCredentialError();
|
|
229
|
+
headers.set("authorization", `Bearer ${this.#token}`);
|
|
230
|
+
const timeout = options?.timeoutMs === void 0 ? void 0 : AbortSignal.timeout(options.timeoutMs);
|
|
231
|
+
const signals = [options?.signal, timeout].filter(
|
|
232
|
+
(candidate) => candidate != null
|
|
233
|
+
);
|
|
234
|
+
const signal = signals.length === 0 ? void 0 : signals.length === 1 ? signals[0] : AbortSignal.any(signals);
|
|
235
|
+
const response = await this.#fetch(
|
|
236
|
+
`${this.#baseUrl}${path}${queryString(params)}`,
|
|
237
|
+
{ headers, signal }
|
|
238
|
+
);
|
|
239
|
+
if (!response.ok) throw await this.#toError(response);
|
|
240
|
+
return await response.text();
|
|
241
|
+
}
|
|
242
|
+
async #toError(response) {
|
|
243
|
+
const retryAfter = response.headers.get("retry-after");
|
|
244
|
+
const fallback = {
|
|
245
|
+
code: `HTTP_${response.status}`,
|
|
246
|
+
message: `Request failed with status ${response.status}`
|
|
247
|
+
};
|
|
248
|
+
const envelope = await response.json().catch(() => null);
|
|
249
|
+
const error = envelope?.error;
|
|
250
|
+
const body = error?.code === void 0 ? fallback : {
|
|
251
|
+
code: error.code,
|
|
252
|
+
message: error.message ?? fallback.message,
|
|
253
|
+
details: error.details
|
|
254
|
+
};
|
|
255
|
+
return toTasqmateError(response.status, body, retryAfter);
|
|
256
|
+
}
|
|
257
|
+
#get(path, params, options) {
|
|
258
|
+
return this.#request(`${path}${queryString(params)}`, options);
|
|
259
|
+
}
|
|
260
|
+
workspaces = {
|
|
261
|
+
list: async () => (await this.#get("/workspaces")).workspaces,
|
|
262
|
+
get: async (slug) => (await this.#get(
|
|
263
|
+
`/workspaces/${encodeURIComponent(slug)}`
|
|
264
|
+
)).workspace
|
|
265
|
+
};
|
|
266
|
+
tasks = {
|
|
267
|
+
list: async (slug, filters) => (await this.#get(
|
|
268
|
+
`/workspaces/${encodeURIComponent(slug)}/tasks`,
|
|
269
|
+
filters
|
|
270
|
+
)).tasks,
|
|
271
|
+
get: async (slug, taskId) => (await this.#get(
|
|
272
|
+
`/workspaces/${encodeURIComponent(slug)}/tasks/${encodeURIComponent(taskId)}`
|
|
273
|
+
)).task,
|
|
274
|
+
/**
|
|
275
|
+
* Ask a person to sign off on a task (6.3). Asking again while a
|
|
276
|
+
* request stands replaces the approver. The approver cannot be an agent.
|
|
277
|
+
*/
|
|
278
|
+
requestApproval: (slug, taskId, approverId) => this.dispatch("task.requestApproval", slug, { taskId, approverId }),
|
|
279
|
+
/**
|
|
280
|
+
* The approver's answer (6.3). `approve` also moves the task to the next
|
|
281
|
+
* status in its team's category order. Person credentials only: no
|
|
282
|
+
* agent policy can include it.
|
|
283
|
+
*/
|
|
284
|
+
decide: (slug, taskId, decision) => this.dispatch("task.decide", slug, { taskId, decision })
|
|
285
|
+
};
|
|
286
|
+
/**
|
|
287
|
+
* Time tracking: whole minutes on a task for a day, no running timer.
|
|
288
|
+
* Everything here is member-level; a guest credential is refused. Turn a
|
|
289
|
+
* typed duration into minutes with `parseDuration`.
|
|
290
|
+
*/
|
|
291
|
+
time = {
|
|
292
|
+
/** A task's entries, newest day first, and its total with direct subtasks. */
|
|
293
|
+
forTask: (slug, taskId) => this.#get(
|
|
294
|
+
`/workspaces/${encodeURIComponent(slug)}/tasks/${encodeURIComponent(taskId)}/time`
|
|
295
|
+
),
|
|
296
|
+
/**
|
|
297
|
+
* Time on a project's tasks between two inclusive `YYYY-MM-DD` days, by
|
|
298
|
+
* person and day. The API reads at most 92 days at a time.
|
|
299
|
+
*/
|
|
300
|
+
forProject: (slug, projectId, range) => this.#get(
|
|
301
|
+
`/workspaces/${encodeURIComponent(slug)}/projects/${encodeURIComponent(projectId)}/time`,
|
|
302
|
+
{ from: range.from, to: range.to }
|
|
303
|
+
),
|
|
304
|
+
/**
|
|
305
|
+
* Log minutes on a task for a day. `memberId` defaults to the caller;
|
|
306
|
+
* logging for someone else is an admin's job.
|
|
307
|
+
*/
|
|
308
|
+
log: (slug, input) => this.dispatch("time.log", slug, input),
|
|
309
|
+
/** Change an entry; omitted fields are left alone, `note: null` clears it. */
|
|
310
|
+
update: (slug, input) => this.dispatch("time.update", slug, input),
|
|
311
|
+
delete: (slug, input) => this.dispatch("time.delete", slug, input)
|
|
312
|
+
};
|
|
313
|
+
/**
|
|
314
|
+
* Clients (initiatives) and their hours. Member-only; refused unless a team
|
|
315
|
+
* with a project for the client has Client hours on.
|
|
316
|
+
*/
|
|
317
|
+
clients = {
|
|
318
|
+
/**
|
|
319
|
+
* One month of a client's hours by billable flag, project and person.
|
|
320
|
+
* `month` is `YYYY-MM`; `billableOnly` counts billable entries only.
|
|
321
|
+
*/
|
|
322
|
+
hours: (slug, clientId, month, options = {}) => this.#get(
|
|
323
|
+
`/workspaces/${encodeURIComponent(slug)}/clients/${encodeURIComponent(clientId)}/hours`,
|
|
324
|
+
{ month, billable: options.billableOnly ? "billable" : "all" }
|
|
325
|
+
),
|
|
326
|
+
/** A client's billing months, newest first, with each one's hours and state. */
|
|
327
|
+
billing: (slug, clientId) => this.#get(
|
|
328
|
+
`/workspaces/${encodeURIComponent(slug)}/clients/${encodeURIComponent(clientId)}/billing`
|
|
329
|
+
)
|
|
330
|
+
};
|
|
331
|
+
/** The caller's own time (TM-2, My week). */
|
|
332
|
+
me = {
|
|
333
|
+
/**
|
|
334
|
+
* The caller's Monday-to-Sunday week around `day` (`YYYY-MM-DD`), that
|
|
335
|
+
* day's entries, and tasks they worked on that day with no time logged.
|
|
336
|
+
* `tz` is the IANA zone that decides which edits fall on the day.
|
|
337
|
+
*/
|
|
338
|
+
week: (slug, day, options = {}) => this.#get(
|
|
339
|
+
`/workspaces/${encodeURIComponent(slug)}/me/week`,
|
|
340
|
+
options.tz ? { day, tz: options.tz } : { day }
|
|
341
|
+
)
|
|
342
|
+
};
|
|
343
|
+
/**
|
|
344
|
+
* Agent timesheet drafts (TM-2). The drafting agent reads a draft and the
|
|
345
|
+
* member's day and saves lines; the member requests, logs, dismisses or
|
|
346
|
+
* replies. Agent keys are refused the member's side by policy.
|
|
347
|
+
*/
|
|
348
|
+
timeDrafts = {
|
|
349
|
+
get: async (slug, draftId) => (await this.#get(
|
|
350
|
+
`/workspaces/${encodeURIComponent(slug)}/time-drafts/${encodeURIComponent(draftId)}`
|
|
351
|
+
)).draft,
|
|
352
|
+
/** The member's week around `day`, read by the agent that drafts it. */
|
|
353
|
+
memberWeek: (slug, memberId, day) => this.#get(
|
|
354
|
+
`/workspaces/${encodeURIComponent(slug)}/members/${encodeURIComponent(memberId)}/week`,
|
|
355
|
+
{ day }
|
|
356
|
+
),
|
|
357
|
+
request: (slug, input) => this.dispatch("timeDraft.request", slug, input),
|
|
358
|
+
save: (slug, input) => this.dispatch("timeDraft.save", slug, input),
|
|
359
|
+
confirm: (slug, input) => this.dispatch("timeDraft.confirm", slug, input),
|
|
360
|
+
dismiss: (slug, input) => this.dispatch("timeDraft.dismiss", slug, input),
|
|
361
|
+
reply: (slug, input) => this.dispatch("timeDraft.reply", slug, input)
|
|
362
|
+
};
|
|
363
|
+
/** Close, invoice and reopen a client's month (admins only). */
|
|
364
|
+
billingPeriods = {
|
|
365
|
+
close: (slug, input) => this.dispatch("billingPeriod.close", slug, input),
|
|
366
|
+
markInvoiced: (slug, input) => this.dispatch("billingPeriod.markInvoiced", slug, input),
|
|
367
|
+
reopen: (slug, input) => this.dispatch("billingPeriod.reopen", slug, input)
|
|
368
|
+
};
|
|
369
|
+
projects = {
|
|
370
|
+
list: async (slug) => (await this.#get(
|
|
371
|
+
`/workspaces/${encodeURIComponent(slug)}/projects`
|
|
372
|
+
)).projects,
|
|
373
|
+
get: async (slug, projectId) => (await this.#get(
|
|
374
|
+
`/workspaces/${encodeURIComponent(slug)}/projects/${encodeURIComponent(projectId)}`
|
|
375
|
+
)).project,
|
|
376
|
+
/**
|
|
377
|
+
* Pin a project to the caller's own sidebar. People only: an agent
|
|
378
|
+
* key is refused by policy whatever its preset.
|
|
379
|
+
*/
|
|
380
|
+
star: (slug, input) => this.dispatch("project.star", slug, input),
|
|
381
|
+
unstar: (slug, input) => this.dispatch("project.unstar", slug, input),
|
|
382
|
+
/**
|
|
383
|
+
* Share a project with a guest already in the workspace (6.2). Admins
|
|
384
|
+
* and the project lead only; an agent key is always refused.
|
|
385
|
+
*/
|
|
386
|
+
grantGuest: (slug, input) => this.dispatch("project.grantGuest", slug, input),
|
|
387
|
+
setGuestAccess: (slug, input) => this.dispatch("project.setGuestAccess", slug, input),
|
|
388
|
+
revokeGuest: (slug, input) => this.dispatch("project.revokeGuest", slug, input)
|
|
389
|
+
};
|
|
390
|
+
/**
|
|
391
|
+
* Docs: plans, specs and notes linked to projects, teams and tasks. Read a
|
|
392
|
+
* body as `bodyMarkdown` and save it back as `bodyMarkdown`: mentions are
|
|
393
|
+
* `[ENG-12](tasq:task/<id>)` and `[Title](tasq:doc/<id>)` links, and a bare
|
|
394
|
+
* `@ENG-12` becomes a mention when it names a task the caller can see.
|
|
395
|
+
* Writes are member-level; an agent needs `doc.*` in its policy.
|
|
396
|
+
*/
|
|
397
|
+
/**
|
|
398
|
+
* Files on tasks, docs and comments (ATT-1). The bytes never pass through
|
|
399
|
+
* the API: `upload` asks for a storage link, PUTs the bytes to it, then
|
|
400
|
+
* confirms. A task's files are on `tasks.get(...).attachments`, a
|
|
401
|
+
* comment's on its `attachments`.
|
|
402
|
+
*/
|
|
403
|
+
attachments = {
|
|
404
|
+
/**
|
|
405
|
+
* Upload a file in one call: `attachment.begin`, the PUT, then
|
|
406
|
+
* `attachment.finish`. With `forComment`, the file is staged for the
|
|
407
|
+
* next `comment.add` that names it in `attachmentIds`.
|
|
408
|
+
*/
|
|
409
|
+
upload: async (slug, target, file, options) => {
|
|
410
|
+
const body = file.data instanceof Blob ? file.data : new Blob([file.data]);
|
|
411
|
+
const contentType = file.contentType ?? (file.data instanceof Blob && file.data.type !== "" ? file.data.type : contentTypeFor(file.fileName));
|
|
412
|
+
const begun = await this.dispatch("attachment.begin", slug, {
|
|
413
|
+
...target,
|
|
414
|
+
fileName: file.fileName,
|
|
415
|
+
contentType,
|
|
416
|
+
sizeBytes: body.size,
|
|
417
|
+
forComment: file.forComment
|
|
418
|
+
});
|
|
419
|
+
const { upload, attachment } = begun.result;
|
|
420
|
+
const put = await this.#fetch(upload.url, {
|
|
421
|
+
method: upload.method,
|
|
422
|
+
headers: upload.headers,
|
|
423
|
+
body,
|
|
424
|
+
signal: options?.signal
|
|
425
|
+
});
|
|
426
|
+
if (!put.ok) {
|
|
427
|
+
throw toTasqmateError(
|
|
428
|
+
put.status,
|
|
429
|
+
{
|
|
430
|
+
code: "UPLOAD_FAILED",
|
|
431
|
+
message: `Storage refused the upload (status ${put.status})`
|
|
432
|
+
},
|
|
433
|
+
null
|
|
434
|
+
);
|
|
435
|
+
}
|
|
436
|
+
return this.dispatch("attachment.finish", slug, {
|
|
437
|
+
attachmentId: attachment.id
|
|
438
|
+
});
|
|
439
|
+
},
|
|
440
|
+
/** A five-minute link to the bytes, with the name, type and size. */
|
|
441
|
+
link: (slug, attachmentId, options) => this.#get(
|
|
442
|
+
`/workspaces/${encodeURIComponent(slug)}/attachments/${encodeURIComponent(attachmentId)}/download`,
|
|
443
|
+
{ link: 1, inline: options?.inline ? 1 : void 0 },
|
|
444
|
+
options
|
|
445
|
+
),
|
|
446
|
+
/** The file's bytes, read through a fresh link. */
|
|
447
|
+
download: async (slug, attachmentId, options) => {
|
|
448
|
+
const link = await this.attachments.link(slug, attachmentId, options);
|
|
449
|
+
const response = await this.#fetch(link.url, { signal: options?.signal });
|
|
450
|
+
if (!response.ok) {
|
|
451
|
+
throw toTasqmateError(
|
|
452
|
+
response.status,
|
|
453
|
+
{
|
|
454
|
+
code: "DOWNLOAD_FAILED",
|
|
455
|
+
message: `Storage refused the download (status ${response.status})`
|
|
456
|
+
},
|
|
457
|
+
null
|
|
458
|
+
);
|
|
459
|
+
}
|
|
460
|
+
return { link, data: await response.arrayBuffer() };
|
|
461
|
+
},
|
|
462
|
+
/** Remove a file: its uploader, or an admin or owner. */
|
|
463
|
+
remove: (slug, attachmentId) => this.dispatch("attachment.remove", slug, { attachmentId })
|
|
464
|
+
};
|
|
465
|
+
docs = {
|
|
466
|
+
/**
|
|
467
|
+
* The library, most recently edited first. With `project` (an id), the
|
|
468
|
+
* project's docs; `mentioning` then lists the docs that only mention
|
|
469
|
+
* one of its tasks.
|
|
470
|
+
*/
|
|
471
|
+
list: (slug, options = {}) => this.#get(
|
|
472
|
+
`/workspaces/${encodeURIComponent(slug)}/docs`,
|
|
473
|
+
{ filter: options.filter ?? "all", project: options.project }
|
|
474
|
+
),
|
|
475
|
+
get: (slug, documentId) => this.#get(
|
|
476
|
+
`/workspaces/${encodeURIComponent(slug)}/docs/${encodeURIComponent(documentId)}`
|
|
477
|
+
),
|
|
478
|
+
/** The docs linked to a task, mentioning it, or mentioned on it. */
|
|
479
|
+
forTask: async (slug, taskId) => (await this.#get(
|
|
480
|
+
`/workspaces/${encodeURIComponent(slug)}/tasks/${encodeURIComponent(taskId)}/docs`
|
|
481
|
+
)).documents,
|
|
482
|
+
create: (slug, input) => this.dispatch("doc.create", slug, input),
|
|
483
|
+
/**
|
|
484
|
+
* Save a title and body. `baseVersion` is the version the edit started
|
|
485
|
+
* from; a save on an older one is a 409 `CONFLICT`.
|
|
486
|
+
*/
|
|
487
|
+
update: (slug, input) => this.dispatch("doc.update", slug, input),
|
|
488
|
+
link: (slug, input) => this.dispatch("doc.link", slug, input),
|
|
489
|
+
unlink: (slug, input) => this.dispatch("doc.unlink", slug, input),
|
|
490
|
+
archive: (slug, documentId) => this.dispatch("doc.archive", slug, { documentId }),
|
|
491
|
+
unarchive: (slug, documentId) => this.dispatch("doc.unarchive", slug, { documentId })
|
|
492
|
+
};
|
|
493
|
+
/**
|
|
494
|
+
* Initiatives group projects across teams. Any member reads them; every
|
|
495
|
+
* write is admin-level, so an agent key (always a member) cannot make one.
|
|
496
|
+
*/
|
|
497
|
+
initiatives = {
|
|
498
|
+
list: async (slug) => (await this.#get(
|
|
499
|
+
`/workspaces/${encodeURIComponent(slug)}/initiatives`
|
|
500
|
+
)).initiatives,
|
|
501
|
+
create: (slug, input) => this.dispatch("initiative.create", slug, input),
|
|
502
|
+
update: (slug, input) => this.dispatch("initiative.update", slug, input),
|
|
503
|
+
delete: (slug, input) => this.dispatch("initiative.delete", slug, input),
|
|
504
|
+
linkProject: (slug, input) => this.dispatch("initiative.linkProject", slug, input),
|
|
505
|
+
unlinkProject: (slug, input) => this.dispatch("initiative.unlinkProject", slug, input)
|
|
506
|
+
};
|
|
507
|
+
/**
|
|
508
|
+
* Project updates: a health call and a body for the project's client (7.5).
|
|
509
|
+
*
|
|
510
|
+
* `draft` is what an agent calls; an agent's update is always a draft
|
|
511
|
+
* whatever it passes. `send` is people only: no agent policy can grant it,
|
|
512
|
+
* because nothing an agent drafts goes to a client without a person
|
|
513
|
+
* approving it.
|
|
514
|
+
*/
|
|
515
|
+
projectUpdates = {
|
|
516
|
+
/**
|
|
517
|
+
* Every update on the project, drafts included, newest first. Follows
|
|
518
|
+
* `nextCursor` until the last page; use `listPage` for one page.
|
|
519
|
+
*/
|
|
520
|
+
list: async (slug, projectId) => {
|
|
521
|
+
const updates = [];
|
|
522
|
+
let before;
|
|
523
|
+
do {
|
|
524
|
+
const page = await this.projectUpdates.listPage(slug, projectId, {
|
|
525
|
+
limit: PROJECT_UPDATES_PAGE_MAX,
|
|
526
|
+
before
|
|
527
|
+
});
|
|
528
|
+
updates.push(...page.updates);
|
|
529
|
+
before = page.nextCursor ?? void 0;
|
|
530
|
+
} while (before !== void 0);
|
|
531
|
+
return updates;
|
|
532
|
+
},
|
|
533
|
+
/**
|
|
534
|
+
* One page of the project's updates, drafts included, newest first; pass
|
|
535
|
+
* `nextCursor` as `before` for the next. The API returns 20 by default,
|
|
536
|
+
* at most 100.
|
|
537
|
+
*/
|
|
538
|
+
listPage: (slug, projectId, query = {}) => this.#get(
|
|
539
|
+
`/workspaces/${encodeURIComponent(slug)}/projects/${encodeURIComponent(projectId)}/updates`,
|
|
540
|
+
{ limit: query.limit, before: query.before }
|
|
541
|
+
),
|
|
542
|
+
draft: (slug, input) => this.dispatch("projectUpdate.create", slug, input),
|
|
543
|
+
create: (slug, input) => this.dispatch("projectUpdate.create", slug, input),
|
|
544
|
+
update: (slug, input) => this.dispatch("projectUpdate.update", slug, input),
|
|
545
|
+
send: (slug, input) => this.dispatch("projectUpdate.send", slug, input),
|
|
546
|
+
delete: (slug, input) => this.dispatch("projectUpdate.delete", slug, input)
|
|
547
|
+
};
|
|
548
|
+
threads = {
|
|
549
|
+
/**
|
|
550
|
+
* The context bundle for one thread: the entity it hangs off, the
|
|
551
|
+
* transcript, recent activity, and the participants (D-6).
|
|
552
|
+
*
|
|
553
|
+
* Authorized by the entity's own read rule, so a read-only agent may
|
|
554
|
+
* pull it. Lists are capped per D-8 with `truncated` flags.
|
|
555
|
+
*/
|
|
556
|
+
context: (slug, threadId, options) => this.#get(
|
|
557
|
+
`/workspaces/${encodeURIComponent(slug)}/threads/${encodeURIComponent(threadId)}/context`,
|
|
558
|
+
void 0,
|
|
559
|
+
options
|
|
560
|
+
)
|
|
561
|
+
};
|
|
562
|
+
cycles = {
|
|
563
|
+
list: async (slug, filters) => (await this.#get(
|
|
564
|
+
`/workspaces/${encodeURIComponent(slug)}/cycles`,
|
|
565
|
+
filters
|
|
566
|
+
)).cycles
|
|
567
|
+
};
|
|
568
|
+
teams = {
|
|
569
|
+
list: async (slug) => (await this.#get(
|
|
570
|
+
`/workspaces/${encodeURIComponent(slug)}/teams`
|
|
571
|
+
)).teams,
|
|
572
|
+
/** The only read that carries a team's statuses. */
|
|
573
|
+
get: async (slug, identifier) => (await this.#get(
|
|
574
|
+
`/workspaces/${encodeURIComponent(slug)}/teams/${encodeURIComponent(identifier)}`
|
|
575
|
+
)).team,
|
|
576
|
+
/**
|
|
577
|
+
* Whether agents on this team may wake each other, plus the loop and
|
|
578
|
+
* fan-out limits that stand behind the open setting (B-04c D-1).
|
|
579
|
+
*
|
|
580
|
+
* Read-only here on purpose: saving the setting is admin-only and web-only
|
|
581
|
+
* (D-8), so no agent key can reach it.
|
|
582
|
+
*/
|
|
583
|
+
agentSettings: (slug, identifier) => this.#get(
|
|
584
|
+
`/workspaces/${encodeURIComponent(slug)}/teams/${encodeURIComponent(identifier)}/agent-settings`
|
|
585
|
+
)
|
|
586
|
+
};
|
|
587
|
+
labels = {
|
|
588
|
+
list: async (slug) => (await this.#get(
|
|
589
|
+
`/workspaces/${encodeURIComponent(slug)}/labels`
|
|
590
|
+
)).labels
|
|
591
|
+
};
|
|
592
|
+
/**
|
|
593
|
+
* Custom fields (6.4): the workspace library, archived fields included.
|
|
594
|
+
* Values are set with `task.setField` and `project.setField`, by field key.
|
|
595
|
+
*/
|
|
596
|
+
fields = {
|
|
597
|
+
list: async (slug) => (await this.#get(
|
|
598
|
+
`/workspaces/${encodeURIComponent(slug)}/fields`
|
|
599
|
+
)).fields,
|
|
600
|
+
/** Set a task's value; null, `[]` or `false` clears it. */
|
|
601
|
+
setTaskValue: (slug, taskId, fieldKey, value) => this.dispatch("task.setField", slug, { taskId, fieldKey, value }),
|
|
602
|
+
/**
|
|
603
|
+
* Set one value on up to 100 tasks, all or nothing: a task whose team
|
|
604
|
+
* has the field off refuses the whole set.
|
|
605
|
+
*/
|
|
606
|
+
bulkSetTaskValue: (slug, taskIds, fieldKey, value) => this.dispatch("task.bulkSetField", slug, { taskIds, fieldKey, value }),
|
|
607
|
+
/** Set a project field's value; null clears it. */
|
|
608
|
+
setProjectValue: (slug, projectId, fieldKey, value) => this.dispatch("project.setField", slug, { projectId, fieldKey, value })
|
|
609
|
+
};
|
|
610
|
+
agents = {
|
|
611
|
+
policy: (slug, agentId) => this.#get(
|
|
612
|
+
`/workspaces/${encodeURIComponent(slug)}/agents/${encodeURIComponent(agentId)}/policy`
|
|
613
|
+
),
|
|
614
|
+
/**
|
|
615
|
+
* Long-poll for mentions addressed to the agent behind this key.
|
|
616
|
+
*
|
|
617
|
+
* The same call acks: ids passed as `ack` are marked before the select
|
|
618
|
+
* runs, so a runner's next poll is also its acknowledgement of the last
|
|
619
|
+
* batch (D-5). Agent keys only.
|
|
620
|
+
*/
|
|
621
|
+
events: (slug, query = {}, options) => this.#get(
|
|
622
|
+
`/workspaces/${encodeURIComponent(slug)}/agents/me/events`,
|
|
623
|
+
{
|
|
624
|
+
wait: query.wait,
|
|
625
|
+
limit: query.limit,
|
|
626
|
+
ack: query.ack === void 0 || query.ack.length === 0 ? void 0 : query.ack.join(",")
|
|
627
|
+
},
|
|
628
|
+
options
|
|
629
|
+
),
|
|
630
|
+
/** The paired bridge behind this agent key, or `bridge: null` (BR-1). */
|
|
631
|
+
bridge: (slug) => this.#get(
|
|
632
|
+
`/workspaces/${encodeURIComponent(slug)}/agents/me/bridge`
|
|
633
|
+
),
|
|
634
|
+
/**
|
|
635
|
+
* Report what the bridge is doing: `running` while it works a wake,
|
|
636
|
+
* then `idle`. Every report is also a sign of life for the presence dot.
|
|
637
|
+
*/
|
|
638
|
+
reportBridgeState: (slug, report) => this.#request(
|
|
639
|
+
`/workspaces/${encodeURIComponent(slug)}/agents/me/bridge/state`,
|
|
640
|
+
{ method: "POST", body: JSON.stringify(report) }
|
|
641
|
+
),
|
|
642
|
+
/** The bridge unpairs itself: its record and this key are revoked. */
|
|
643
|
+
unpairBridge: (slug) => this.#request(
|
|
644
|
+
`/workspaces/${encodeURIComponent(slug)}/agents/me/bridge`,
|
|
645
|
+
{ method: "DELETE" }
|
|
646
|
+
)
|
|
647
|
+
};
|
|
648
|
+
/**
|
|
649
|
+
* Pairing a Tasqmate Bridge (BR-1). Both calls are anonymous: the bridge
|
|
650
|
+
* has no credential until a person approves it, and the device code is
|
|
651
|
+
* the secret it collects its key with.
|
|
652
|
+
*/
|
|
653
|
+
bridge = {
|
|
654
|
+
startPairing: (report) => this.#request("/bridge/pairings", {
|
|
655
|
+
method: "POST",
|
|
656
|
+
body: JSON.stringify(report),
|
|
657
|
+
anonymous: true
|
|
658
|
+
}),
|
|
659
|
+
/** Ask once whether the pairing was approved; the key comes back exactly once. */
|
|
660
|
+
pollPairing: (deviceCode) => this.#request("/bridge/pairings/token", {
|
|
661
|
+
method: "POST",
|
|
662
|
+
body: JSON.stringify({ deviceCode }),
|
|
663
|
+
anonymous: true
|
|
664
|
+
})
|
|
665
|
+
};
|
|
666
|
+
/**
|
|
667
|
+
* Agent routines (AR-1): schedules that wake an agent with a prompt. A
|
|
668
|
+
* routine only emits a `routine` event at its time; the runner pulls it
|
|
669
|
+
* with `agents.events` and acts. Managing routines takes an owner or admin
|
|
670
|
+
* session or user key; agent keys can list them but never change them.
|
|
671
|
+
*/
|
|
672
|
+
routines = {
|
|
673
|
+
list: async (slug, query = {}) => (await this.#get(
|
|
674
|
+
`/workspaces/${encodeURIComponent(slug)}/agent-console/routines`,
|
|
675
|
+
{ agent: query.agent }
|
|
676
|
+
)).routines,
|
|
677
|
+
create: (slug, input) => this.dispatch("routine.create", slug, input),
|
|
678
|
+
update: (slug, input) => this.dispatch("routine.update", slug, input),
|
|
679
|
+
pause: (slug, routineId) => this.dispatch("routine.pause", slug, { routineId }),
|
|
680
|
+
resume: (slug, routineId) => this.dispatch("routine.resume", slug, { routineId }),
|
|
681
|
+
delete: (slug, routineId) => this.dispatch("routine.delete", slug, { routineId }),
|
|
682
|
+
/** Wake the agent now; the schedule stays where it was. */
|
|
683
|
+
runNow: (slug, routineId) => this.dispatch("routine.runNow", slug, { routineId })
|
|
684
|
+
};
|
|
685
|
+
/**
|
|
686
|
+
* Releases: the structural record of a cycle close, and the narrative an
|
|
687
|
+
* agent or a person attaches to it (B-04d).
|
|
688
|
+
*
|
|
689
|
+
* Reads are authorized by the workspace role guard rather than a policy
|
|
690
|
+
* action, so a read-only agent may pull the context it needs; the write
|
|
691
|
+
* goes through `release.saveNarrative` like every other action.
|
|
692
|
+
*/
|
|
693
|
+
releases = {
|
|
694
|
+
list: async (slug, teamIdentifier) => (await this.#get(
|
|
695
|
+
`/workspaces/${encodeURIComponent(slug)}/releases`,
|
|
696
|
+
{ team: teamIdentifier }
|
|
697
|
+
)).releases,
|
|
698
|
+
get: async (slug, releaseId) => (await this.#get(
|
|
699
|
+
`/workspaces/${encodeURIComponent(slug)}/releases/${encodeURIComponent(releaseId)}`
|
|
700
|
+
)).release,
|
|
701
|
+
/**
|
|
702
|
+
* The context bundle a narrator writes from.
|
|
703
|
+
*
|
|
704
|
+
* `format: "markdown"` returns the server-rendered prompt as a string,
|
|
705
|
+
* which is what a harness pastes into a model; the default returns the
|
|
706
|
+
* bundle, for a runner that branches on the fields itself.
|
|
707
|
+
*/
|
|
708
|
+
context: ((slug, releaseId, options = {}) => {
|
|
709
|
+
const path = `/workspaces/${encodeURIComponent(slug)}/releases/${encodeURIComponent(releaseId)}/context`;
|
|
710
|
+
return options.format === "markdown" ? this.#text(path, { format: "markdown" }, options) : this.#get(path, void 0, options);
|
|
711
|
+
}),
|
|
712
|
+
diff: async (slug, releaseId) => (await this.#get(
|
|
713
|
+
`/workspaces/${encodeURIComponent(slug)}/releases/${encodeURIComponent(releaseId)}/diff`
|
|
714
|
+
)).diff,
|
|
715
|
+
/** The release as a Markdown document, the same body the web export serves. */
|
|
716
|
+
export: (slug, releaseId) => this.#text(
|
|
717
|
+
`/workspaces/${encodeURIComponent(slug)}/releases/${encodeURIComponent(releaseId)}/export`
|
|
718
|
+
),
|
|
719
|
+
/** Last write wins; the author and timestamp move with the body (D-3). */
|
|
720
|
+
saveNarrative: (slug, input) => this.dispatch("release.saveNarrative", slug, input)
|
|
721
|
+
};
|
|
722
|
+
members = {
|
|
723
|
+
list: async (slug) => (await this.#get(
|
|
724
|
+
`/workspaces/${encodeURIComponent(slug)}/members`
|
|
725
|
+
)).members
|
|
726
|
+
};
|
|
727
|
+
notifications = {
|
|
728
|
+
list: (slug, query = {}) => this.#get(
|
|
729
|
+
`/workspaces/${encodeURIComponent(slug)}/notifications`,
|
|
730
|
+
{ unread: query.unread === true ? 1 : void 0 }
|
|
731
|
+
)
|
|
732
|
+
};
|
|
733
|
+
activity = {
|
|
734
|
+
/** The workspace activity feed, newest first; page with `nextCursor`. */
|
|
735
|
+
list: (slug, query = {}) => this.#get(
|
|
736
|
+
`/workspaces/${encodeURIComponent(slug)}/activity`,
|
|
737
|
+
{ limit: query.limit, before: query.before }
|
|
738
|
+
)
|
|
739
|
+
};
|
|
740
|
+
waiting = {
|
|
741
|
+
/** Approvals and agent drafts waiting on the caller. People only. */
|
|
742
|
+
get: (slug) => this.#get(
|
|
743
|
+
`/workspaces/${encodeURIComponent(slug)}/waiting`
|
|
744
|
+
)
|
|
745
|
+
};
|
|
746
|
+
auth = {
|
|
747
|
+
/** The principal behind the current credential. */
|
|
748
|
+
me: async () => (await this.#get("/auth/me")).user,
|
|
749
|
+
/** Step one of CLI login: mail a sign-in code. Needs no credential. */
|
|
750
|
+
requestMagicLink: async (input) => {
|
|
751
|
+
await this.#request("/auth/magic-link", {
|
|
752
|
+
method: "POST",
|
|
753
|
+
body: JSON.stringify({ email: input.email }),
|
|
754
|
+
anonymous: true
|
|
755
|
+
});
|
|
756
|
+
},
|
|
757
|
+
/** Step two: exchange the code for a `tq_us_…` token. Needs no credential. */
|
|
758
|
+
verifyCliCode: (input) => this.#request("/auth/cli/verify-code", {
|
|
759
|
+
method: "POST",
|
|
760
|
+
body: JSON.stringify(input),
|
|
761
|
+
anonymous: true
|
|
762
|
+
}),
|
|
763
|
+
/** Revoke the user token this client authenticates with. */
|
|
764
|
+
revokeUserToken: async () => {
|
|
765
|
+
await this.#request("/auth/cli/token", { method: "DELETE" });
|
|
766
|
+
}
|
|
767
|
+
};
|
|
768
|
+
/** Run a write action. The API validates `input`; the SDK does not. */
|
|
769
|
+
dispatch(action, slug, input) {
|
|
770
|
+
return this.#request(
|
|
771
|
+
`/workspaces/${encodeURIComponent(slug)}/actions`,
|
|
772
|
+
{ method: "POST", body: JSON.stringify({ action, input }) }
|
|
773
|
+
);
|
|
774
|
+
}
|
|
775
|
+
};
|
|
776
|
+
|
|
777
|
+
// src/time.ts
|
|
778
|
+
var DURATION_FORMS = "1h 30m, 1h30m, 90m, 1.5h, 1:30 or a bare number of hours";
|
|
779
|
+
function parseDuration(raw) {
|
|
780
|
+
const value = raw.trim().toLowerCase().replace(/\s+/g, "");
|
|
781
|
+
if (!value) return null;
|
|
782
|
+
let match = value.match(/^(\d{1,2}):([0-5]\d)$/);
|
|
783
|
+
if (match) return Number(match[1]) * 60 + Number(match[2]);
|
|
784
|
+
match = value.match(/^(\d+(?:\.\d+)?)h$/);
|
|
785
|
+
if (match) return Math.round(Number(match[1]) * 60);
|
|
786
|
+
match = value.match(/^(\d+)m(?:in|ins)?$/);
|
|
787
|
+
if (match) return Number(match[1]);
|
|
788
|
+
match = value.match(/^(\d+)h(\d+)m?(?:in|ins)?$/);
|
|
789
|
+
if (match) return Number(match[1]) * 60 + Number(match[2]);
|
|
790
|
+
match = value.match(/^(\d+(?:\.\d+)?)$/);
|
|
791
|
+
if (match) return Math.round(Number(match[1]) * 60);
|
|
792
|
+
return null;
|
|
793
|
+
}
|
|
794
|
+
function formatMinutes(minutes) {
|
|
795
|
+
const hours = Math.floor(minutes / 60);
|
|
796
|
+
const rest = minutes % 60;
|
|
797
|
+
if (hours === 0) return `${rest}m`;
|
|
798
|
+
return rest === 0 ? `${hours}h` : `${hours}h ${rest}m`;
|
|
799
|
+
}
|
|
800
|
+
|
|
801
|
+
// src/types.ts
|
|
802
|
+
var PROJECT_HEALTH_VALUES = [
|
|
803
|
+
"on_track",
|
|
804
|
+
"at_risk",
|
|
805
|
+
"off_track"
|
|
806
|
+
];
|
|
807
|
+
var THREAD_CONTEXT_MESSAGE_LIMIT = 50;
|
|
808
|
+
var THREAD_CONTEXT_ACTIVITY_LIMIT = 20;
|
|
809
|
+
var THREAD_CONTEXT_DESCRIPTION_MAX = 8e3;
|
|
810
|
+
var AGENT_ISOLATION_VALUES = ["isolated", "open"];
|
|
811
|
+
var SUPPRESSED_REASONS = [
|
|
812
|
+
"isolation",
|
|
813
|
+
"fanout_cap",
|
|
814
|
+
"loop_cap",
|
|
815
|
+
"guest_actor",
|
|
816
|
+
"policy_kind",
|
|
817
|
+
"policy_sender",
|
|
818
|
+
"policy_scope"
|
|
819
|
+
];
|
|
820
|
+
var MAX_AGENT_WAKES_PER_MESSAGE = 10;
|
|
821
|
+
var MAX_CONSECUTIVE_AGENT_MESSAGES = 5;
|
|
822
|
+
var RELEASE_DISPOSITIONS = [
|
|
823
|
+
"shipped",
|
|
824
|
+
"carried_over",
|
|
825
|
+
"dropped"
|
|
826
|
+
];
|
|
827
|
+
var RELEASE_NARRATIVE_MAX = 5e4;
|
|
828
|
+
var RELEASE_NARRATIVE_EXCERPT_MAX = 500;
|
|
829
|
+
var RELEASE_CONTEXT_TASK_LIMIT = 100;
|
|
830
|
+
var DOCUMENT_FILTERS = [
|
|
831
|
+
"all",
|
|
832
|
+
"workspace",
|
|
833
|
+
"projects",
|
|
834
|
+
"teams",
|
|
835
|
+
"mine",
|
|
836
|
+
"templates",
|
|
837
|
+
"archived"
|
|
838
|
+
];
|
|
839
|
+
export {
|
|
840
|
+
AGENT_ISOLATION_VALUES,
|
|
841
|
+
AGENT_KEY_PREFIX,
|
|
842
|
+
DOCUMENT_FILTERS,
|
|
843
|
+
DURATION_FORMS,
|
|
844
|
+
MAX_AGENT_WAKES_PER_MESSAGE,
|
|
845
|
+
MAX_CONSECUTIVE_AGENT_MESSAGES,
|
|
846
|
+
PROJECT_HEALTH_VALUES,
|
|
847
|
+
RELEASE_CONTEXT_TASK_LIMIT,
|
|
848
|
+
RELEASE_DISPOSITIONS,
|
|
849
|
+
RELEASE_NARRATIVE_EXCERPT_MAX,
|
|
850
|
+
RELEASE_NARRATIVE_MAX,
|
|
851
|
+
SUPPRESSED_REASONS,
|
|
852
|
+
THREAD_CONTEXT_ACTIVITY_LIMIT,
|
|
853
|
+
THREAD_CONTEXT_DESCRIPTION_MAX,
|
|
854
|
+
THREAD_CONTEXT_MESSAGE_LIMIT,
|
|
855
|
+
TasqmateApiError,
|
|
856
|
+
TasqmateClient,
|
|
857
|
+
TasqmatePolicyDeniedError,
|
|
858
|
+
TasqmateRateLimitError,
|
|
859
|
+
TasqmateValidationError,
|
|
860
|
+
USER_TOKEN_PREFIX,
|
|
861
|
+
contentTypeFor,
|
|
862
|
+
formatFileSize,
|
|
863
|
+
formatMinutes,
|
|
864
|
+
parseDuration
|
|
865
|
+
};
|
|
866
|
+
//# sourceMappingURL=index.js.map
|