@work-shape/catalyst-cli 0.8.0-rc.30 → 0.8.0-rc.32
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 +2 -2
- package/dist/index.d.ts +355 -15
- package/dist/index.js +575 -129
- package/package.json +4 -4
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
// src/index.ts
|
|
4
|
-
import { realpathSync } from "fs";
|
|
4
|
+
import { realpathSync as realpathSync2 } from "fs";
|
|
5
5
|
import { pathToFileURL } from "url";
|
|
6
6
|
|
|
7
7
|
// ../asset-schemas/src/asset-types.ts
|
|
@@ -89,7 +89,10 @@ var CONNECTION_ACTIONS = [
|
|
|
89
89
|
"connection.use",
|
|
90
90
|
"connection.write",
|
|
91
91
|
"connection.delete",
|
|
92
|
-
"connection.approve"
|
|
92
|
+
"connection.approve",
|
|
93
|
+
// Adding one's own MCP server, a Connection only its owner uses (PMCP). The role `user`
|
|
94
|
+
// holds it by default; it names no Connection.
|
|
95
|
+
"connection.add_own"
|
|
93
96
|
];
|
|
94
97
|
|
|
95
98
|
// ../asset-schemas/src/contract-values/app.ts
|
|
@@ -319,6 +322,7 @@ var PROVIDER_CHECK_ERROR_CLASSES = [
|
|
|
319
322
|
var CONNECTION_NAME_PATTERN = /^[a-z][a-z0-9]*([_-][a-z0-9]+)*$/u;
|
|
320
323
|
var CONNECTION_NAME_MAX_LENGTH = 64;
|
|
321
324
|
var CONNECTION_EXPOSURES = ["agent", "bridge", "workflow", "outside"];
|
|
325
|
+
var CONNECTOR_FORM_FIELD_VALUES = ["text", "number", "list"];
|
|
322
326
|
var CONNECTION_HEALTH_STATES = [
|
|
323
327
|
"unknown",
|
|
324
328
|
"ok",
|
|
@@ -333,6 +337,7 @@ var ASSET_MOVE_EDITORS = ["workspace_builders", "instance_builders"];
|
|
|
333
337
|
var ASSET_MOVE_USERS = ["workspace_members", "everyone_where_offered"];
|
|
334
338
|
var GRANT_HOLDER_KINDS = ["user", "service_principal", "role", "group"];
|
|
335
339
|
var GRANT_SCOPE_KINDS = ["instance", "workspace", "asset"];
|
|
340
|
+
var ASSET_RIGHT_VERBS = ["read", "use", "write", "delete"];
|
|
336
341
|
var ROLE_GRANT_SCOPE_KINDS = [
|
|
337
342
|
"instance",
|
|
338
343
|
"workspace",
|
|
@@ -439,7 +444,7 @@ var ASSET_LIFECYCLES = ["active", "draft_published"];
|
|
|
439
444
|
var ASSET_REPRESENTATIONS = ["config", "files"];
|
|
440
445
|
var CONFIG_ASSET_KINDS = ["agent", "skill"];
|
|
441
446
|
var CONFIG_ASSET_CHANGE_OPERATIONS = ["create", "update", "delete", "revert"];
|
|
442
|
-
var AGENT_AVAILABILITY_MODES = ["all", "selected"];
|
|
447
|
+
var AGENT_AVAILABILITY_MODES = ["all", "selected", "all_except"];
|
|
443
448
|
var AGENT_USE_SETTINGS = ["everyone", "granted"];
|
|
444
449
|
var AGENT_EDITABLE_FIELDS = [
|
|
445
450
|
"displayName",
|
|
@@ -591,7 +596,12 @@ var CONNECTOR_TEST_STATUSES = [
|
|
|
591
596
|
"network_denied",
|
|
592
597
|
"unavailable",
|
|
593
598
|
/** The server asks for an OAuth sign-in, or the Connection signs in and nobody has. */
|
|
594
|
-
"oauth_required"
|
|
599
|
+
"oauth_required",
|
|
600
|
+
/**
|
|
601
|
+
* A person's own server refuses a request without a credential and describes no sign-in:
|
|
602
|
+
* it takes a token (PMCP).
|
|
603
|
+
*/
|
|
604
|
+
"token_required"
|
|
595
605
|
];
|
|
596
606
|
var CONNECTION_CREDENTIAL_MODES = ["shared", "user"];
|
|
597
607
|
var CONNECTION_BINDING_STATES = ["connected", "needs_reconnect", "revoked"];
|
|
@@ -1625,6 +1635,19 @@ var sourceStatusSchema = z4.strictObject({
|
|
|
1625
1635
|
last: knowledgeSyncResultSchema.optional(),
|
|
1626
1636
|
/** "Wartet auf Bestätigung": the running first pass stopped at 10,000 items. */
|
|
1627
1637
|
confirmation: knowledgeFirstPassConfirmationSchema.optional(),
|
|
1638
|
+
/**
|
|
1639
|
+
* When a connector source syncs by itself (SRC-SYNC), as it applies: its `changes` poll in
|
|
1640
|
+
* minutes or `off`, its full pass as a cron expression in the instance's time zone or `off`,
|
|
1641
|
+
* and what its connector type gives a source that sets none: the poll, the full pass, and the
|
|
1642
|
+
* shortest poll the type allows, where it has one.
|
|
1643
|
+
*/
|
|
1644
|
+
schedule: z4.strictObject({
|
|
1645
|
+
changes: z4.union([z4.literal("off"), z4.number().int().min(1)]),
|
|
1646
|
+
full: z4.string(),
|
|
1647
|
+
defaultChanges: z4.number().int().min(1),
|
|
1648
|
+
defaultFull: z4.string(),
|
|
1649
|
+
minChanges: z4.number().int().min(1).optional()
|
|
1650
|
+
}).optional(),
|
|
1628
1651
|
/** "Letzte Änderung verarbeitet". */
|
|
1629
1652
|
lastChangeAt: z4.string().optional(),
|
|
1630
1653
|
/** "Älteste offene Änderung". */
|
|
@@ -2807,7 +2830,7 @@ import { z as z68 } from "zod";
|
|
|
2807
2830
|
// ../api-contract/package.json
|
|
2808
2831
|
var package_default = {
|
|
2809
2832
|
name: "@work-shape/catalyst-api-contract",
|
|
2810
|
-
version: "0.8.0-rc.
|
|
2833
|
+
version: "0.8.0-rc.32",
|
|
2811
2834
|
license: "MIT",
|
|
2812
2835
|
repository: {
|
|
2813
2836
|
type: "git",
|
|
@@ -3121,7 +3144,7 @@ var accessOriginRoleSchema = z22.object({
|
|
|
3121
3144
|
});
|
|
3122
3145
|
var REFUSAL_REASONS = ["denied", "no_grant", "holder_inactive"];
|
|
3123
3146
|
var refusalReasonSchema = z22.enum(REFUSAL_REASONS);
|
|
3124
|
-
var ASSET_CHECK_VERBS =
|
|
3147
|
+
var ASSET_CHECK_VERBS = ASSET_RIGHT_VERBS;
|
|
3125
3148
|
var assetCheckVerbSchema = z22.enum(ASSET_CHECK_VERBS);
|
|
3126
3149
|
var holderRightsSchema = z22.object({
|
|
3127
3150
|
holderActive: z22.boolean(),
|
|
@@ -4767,6 +4790,13 @@ var listAssetsQuerySchema = z30.object({
|
|
|
4767
4790
|
/** Only assets whose name or title contains this text, whatever the case. */
|
|
4768
4791
|
text: nameText(z30.string().min(1).max(200)).optional(),
|
|
4769
4792
|
workspaceId: workspaceIdSchema,
|
|
4793
|
+
/**
|
|
4794
|
+
* One page across several owners, in place of `workspaceId`: `instance` and workspace ids,
|
|
4795
|
+
* separated by commas. Each asset is listed by the same right as in its owner's own list.
|
|
4796
|
+
*/
|
|
4797
|
+
owners: nameText(
|
|
4798
|
+
z30.string().min(1).max(1e4).regex(/^[^,]+(?:,[^,]+)*$/u, "owners separated by commas")
|
|
4799
|
+
).optional(),
|
|
4770
4800
|
/**
|
|
4771
4801
|
* The language of the titles and descriptions, where a kind holds them in several. A
|
|
4772
4802
|
* language the instance does not offer, or none, answers its default.
|
|
@@ -5597,6 +5627,11 @@ var conversationSubjectSchema = z33.object({
|
|
|
5597
5627
|
name: z33.string().min(1).max(200)
|
|
5598
5628
|
});
|
|
5599
5629
|
var conversationCreationTargetSchema = z33.literal("instance");
|
|
5630
|
+
var conversationPersonSchema = z33.object({
|
|
5631
|
+
userId: z33.string(),
|
|
5632
|
+
displayLabel: z33.string(),
|
|
5633
|
+
addedAt: timestampSchema
|
|
5634
|
+
});
|
|
5600
5635
|
var conversationSchema = z33.object({
|
|
5601
5636
|
id: z33.string(),
|
|
5602
5637
|
clientInstanceId: z33.string(),
|
|
@@ -5615,7 +5650,40 @@ var conversationSchema = z33.object({
|
|
|
5615
5650
|
/** `instance`: its first saves create agents, skills and guardrails for the instance. */
|
|
5616
5651
|
creationTarget: conversationCreationTargetSchema.optional(),
|
|
5617
5652
|
/** The project of its workspace it is in; its readers are the project's audience. */
|
|
5618
|
-
projectId: z33.string().optional()
|
|
5653
|
+
projectId: z33.string().optional(),
|
|
5654
|
+
/**
|
|
5655
|
+
* The members of its workspace its creator named, who read and write in this private chat
|
|
5656
|
+
* while members (CHAT-SHARE). Empty on every other conversation; a run thread carries its
|
|
5657
|
+
* root's.
|
|
5658
|
+
*/
|
|
5659
|
+
people: z33.array(conversationPersonSchema),
|
|
5660
|
+
/**
|
|
5661
|
+
* The creator's name, on a chat that names people: its other readers see who started it and
|
|
5662
|
+
* who wrote each turn. Missing on every other conversation.
|
|
5663
|
+
*/
|
|
5664
|
+
createdByDisplayLabel: z33.string().optional()
|
|
5665
|
+
});
|
|
5666
|
+
var addConversationPersonRequestSchema = z33.object({ userId: z33.string().min(1) }).strict();
|
|
5667
|
+
var conversationPersonRemovedSchema = z33.object({
|
|
5668
|
+
conversationId: z33.string(),
|
|
5669
|
+
userId: z33.string(),
|
|
5670
|
+
removed: z33.boolean()
|
|
5671
|
+
});
|
|
5672
|
+
var SHARE_CANDIDATES_QUERY_MAX_CHARS = 200;
|
|
5673
|
+
var SHARE_CANDIDATES_LIMIT_MAX = 50;
|
|
5674
|
+
var shareCandidatesQuerySchema = z33.object({
|
|
5675
|
+
/** A prefix of a name, of a word of the name, or of an email, among the people offered. */
|
|
5676
|
+
query: z33.string().trim().min(1).max(SHARE_CANDIDATES_QUERY_MAX_CHARS).optional(),
|
|
5677
|
+
limit: z33.coerce.number().int().min(1).max(SHARE_CANDIDATES_LIMIT_MAX).default(5)
|
|
5678
|
+
});
|
|
5679
|
+
var conversationShareCandidateSchema = z33.object({
|
|
5680
|
+
userId: z33.string(),
|
|
5681
|
+
displayLabel: z33.string(),
|
|
5682
|
+
email: z33.string().optional(),
|
|
5683
|
+
hasAccess: z33.boolean()
|
|
5684
|
+
});
|
|
5685
|
+
var conversationShareCandidatesSchema = z33.object({
|
|
5686
|
+
candidates: z33.array(conversationShareCandidateSchema)
|
|
5619
5687
|
});
|
|
5620
5688
|
var moveConversationRequestSchema = z33.object({
|
|
5621
5689
|
collaborationWorkspaceId: z33.string().min(1),
|
|
@@ -5664,7 +5732,12 @@ var knowledgeCitationSourceSchema = z33.object({
|
|
|
5664
5732
|
fileId: z33.string().min(1),
|
|
5665
5733
|
fileName: z33.string().min(1),
|
|
5666
5734
|
page: z33.number().int().positive().optional(),
|
|
5667
|
-
|
|
5735
|
+
sheet: z33.string().min(1).optional(),
|
|
5736
|
+
originLink: z33.string().optional(),
|
|
5737
|
+
/** The date the cited synced document states of its version, shown on its chip. ISO. */
|
|
5738
|
+
statedAt: z33.string().optional(),
|
|
5739
|
+
/** When the platform fetched it, shown on the chip where no date is stated. ISO. */
|
|
5740
|
+
retrievedAt: z33.string().optional()
|
|
5668
5741
|
});
|
|
5669
5742
|
var messageCitationSchema = z33.object({
|
|
5670
5743
|
sourceId: z33.string(),
|
|
@@ -6449,7 +6522,22 @@ var conversationThreadSnapshotSchema = z33.object({
|
|
|
6449
6522
|
* The agent of each run the conversation held, oldest first, by the message that started the
|
|
6450
6523
|
* run: where another agent answers from that message on, the history says so (T30).
|
|
6451
6524
|
*/
|
|
6452
|
-
runAgents: z33.array(
|
|
6525
|
+
runAgents: z33.array(
|
|
6526
|
+
z33.object({
|
|
6527
|
+
inputMessageId: z33.string(),
|
|
6528
|
+
agentName: z33.string(),
|
|
6529
|
+
/**
|
|
6530
|
+
* The person the run acts for, on a chat that names people or that more than one person
|
|
6531
|
+
* wrote in (CHAT-SHARE-2).
|
|
6532
|
+
*/
|
|
6533
|
+
ownerUserId: z33.string().optional(),
|
|
6534
|
+
/**
|
|
6535
|
+
* That person's name, on the same chats: their turns stay attributed after they leave
|
|
6536
|
+
* it or are removed. Missing where the account is gone.
|
|
6537
|
+
*/
|
|
6538
|
+
ownerDisplayLabel: z33.string().optional()
|
|
6539
|
+
})
|
|
6540
|
+
).optional(),
|
|
6453
6541
|
/**
|
|
6454
6542
|
* What the conversation's latest run was asked to use. Absent before the first run; a run that
|
|
6455
6543
|
* followed the configured defaults leaves both fields out.
|
|
@@ -7460,6 +7548,11 @@ var approvalRequestSchema = z38.object({
|
|
|
7460
7548
|
* Absent on a request the holders of a right decide.
|
|
7461
7549
|
*/
|
|
7462
7550
|
addresseeUserId: z38.string().optional(),
|
|
7551
|
+
/**
|
|
7552
|
+
* The requester held the right that decides it when filing. Pending, it is listed in To
|
|
7553
|
+
* decide for them alone; the other holders of the right find it with `scope=others_own`.
|
|
7554
|
+
*/
|
|
7555
|
+
requesterDecides: z38.literal(true).optional(),
|
|
7463
7556
|
status: approvalRequestStatusSchema,
|
|
7464
7557
|
decision: z38.object({
|
|
7465
7558
|
approved: z38.boolean(),
|
|
@@ -7481,10 +7574,15 @@ var approvalRequestViewSchema = approvalRequestSchema.extend({
|
|
|
7481
7574
|
canWithdraw: z38.boolean(),
|
|
7482
7575
|
canRevert: z38.boolean()
|
|
7483
7576
|
});
|
|
7577
|
+
var APPROVAL_REQUEST_LIST_SCOPES = ["decided", "others_own"];
|
|
7484
7578
|
var listApprovalRequestsQuerySchema = z38.object({
|
|
7485
7579
|
status: approvalRequestStatusSchema.optional(),
|
|
7486
|
-
/**
|
|
7487
|
-
|
|
7580
|
+
/**
|
|
7581
|
+
* `decided`: the requests that are no longer pending and changed in the last 30 days.
|
|
7582
|
+
* `others_own`: the pending requests other people filed who may decide them themselves,
|
|
7583
|
+
* which the plain list leaves out.
|
|
7584
|
+
*/
|
|
7585
|
+
scope: z38.enum(APPROVAL_REQUEST_LIST_SCOPES).optional()
|
|
7488
7586
|
});
|
|
7489
7587
|
var pendingApprovalRequestCountSchema = z38.object({
|
|
7490
7588
|
/** The pending requests the caller can decide. */
|
|
@@ -7492,6 +7590,11 @@ var pendingApprovalRequestCountSchema = z38.object({
|
|
|
7492
7590
|
canReview: z38.boolean(),
|
|
7493
7591
|
/** How many requests the list with `scope=decided` holds for the caller. */
|
|
7494
7592
|
decided: z38.number().int().nonnegative(),
|
|
7593
|
+
/**
|
|
7594
|
+
* How many pending requests the list with `scope=others_own` holds: not in `count`, since
|
|
7595
|
+
* their requesters decide them themselves.
|
|
7596
|
+
*/
|
|
7597
|
+
othersOwn: z38.number().int().nonnegative(),
|
|
7495
7598
|
/** The requests the caller made: those still pending, and all of them. */
|
|
7496
7599
|
mine: z38.object({
|
|
7497
7600
|
pending: z38.number().int().nonnegative(),
|
|
@@ -9033,9 +9136,27 @@ var connectorTypeOffersSchema = z44.object({
|
|
|
9033
9136
|
help: localizedTextSchema.optional(),
|
|
9034
9137
|
optional: z44.boolean(),
|
|
9035
9138
|
setting: z44.string().optional(),
|
|
9036
|
-
secret: z44.boolean()
|
|
9139
|
+
secret: z44.boolean(),
|
|
9140
|
+
/** What a setting holds: a whole number or a list of names. Text where left out. */
|
|
9141
|
+
value: z44.enum(CONNECTOR_FORM_FIELD_VALUES).optional(),
|
|
9142
|
+
/** What the field starts with. Never for the secret. */
|
|
9143
|
+
default: z44.string().optional(),
|
|
9144
|
+
/** The field folds away under "Technical details". */
|
|
9145
|
+
advanced: z44.literal(true).optional()
|
|
9037
9146
|
})
|
|
9038
|
-
)
|
|
9147
|
+
),
|
|
9148
|
+
/** Whose account everyone reads, before the secret and where the setup asks who may use it. */
|
|
9149
|
+
sharedAccountNote: localizedTextSchema.optional(),
|
|
9150
|
+
/** The type's own operations, approved after Verbinden. Empty for a type without a catalog. */
|
|
9151
|
+
operations: z44.array(
|
|
9152
|
+
z44.object({
|
|
9153
|
+
name: z44.string(),
|
|
9154
|
+
description: z44.string(),
|
|
9155
|
+
effect: connectionOperationEffectSchema
|
|
9156
|
+
})
|
|
9157
|
+
),
|
|
9158
|
+
/** Where an approved operation may be used: only by agents for a type whose results are private. */
|
|
9159
|
+
exposures: z44.array(z44.enum(CONNECTION_EXPOSURES))
|
|
9039
9160
|
})
|
|
9040
9161
|
),
|
|
9041
9162
|
/**
|
|
@@ -10285,6 +10406,53 @@ var conversationOperations = {
|
|
|
10285
10406
|
errors: ["NOT_FOUND", "CONFLICT"],
|
|
10286
10407
|
rateClass: "write"
|
|
10287
10408
|
}),
|
|
10409
|
+
// Who reads a private chat beside its creator (CHAT-SHARE). Only the person in their own
|
|
10410
|
+
// session changes it: never an agent tool, and a key or a delegated actor is refused by the
|
|
10411
|
+
// service whatever its scopes.
|
|
10412
|
+
"conversations.add_person": defineOperation({
|
|
10413
|
+
id: "conversations.add_person",
|
|
10414
|
+
method: "POST",
|
|
10415
|
+
path: "/api/v1/conversations/:conversationId/people",
|
|
10416
|
+
summary: "Name a member of the chat's workspace to read and write in the creator's private chat",
|
|
10417
|
+
tag: "Conversations",
|
|
10418
|
+
auth: "user",
|
|
10419
|
+
scope: "conversation:write",
|
|
10420
|
+
requires: [],
|
|
10421
|
+
effect: "changing",
|
|
10422
|
+
body: addConversationPersonRequestSchema,
|
|
10423
|
+
response: json(conversationSchema),
|
|
10424
|
+
errors: ["NOT_FOUND", "FORBIDDEN", "CONFLICT", "VALIDATION_FAILED"],
|
|
10425
|
+
rateClass: "write"
|
|
10426
|
+
}),
|
|
10427
|
+
"conversations.remove_person": defineOperation({
|
|
10428
|
+
id: "conversations.remove_person",
|
|
10429
|
+
method: "DELETE",
|
|
10430
|
+
path: "/api/v1/conversations/:conversationId/people/:userId",
|
|
10431
|
+
summary: "Take a named person off a private chat: its creator removes anyone, a named person leaves",
|
|
10432
|
+
tag: "Conversations",
|
|
10433
|
+
auth: "user",
|
|
10434
|
+
scope: "conversation:write",
|
|
10435
|
+
requires: [],
|
|
10436
|
+
effect: "changing",
|
|
10437
|
+
response: json(conversationPersonRemovedSchema),
|
|
10438
|
+
errors: ["NOT_FOUND", "FORBIDDEN", "CONFLICT"],
|
|
10439
|
+
rateClass: "write"
|
|
10440
|
+
}),
|
|
10441
|
+
"conversations.share_candidates": defineOperation({
|
|
10442
|
+
id: "conversations.share_candidates",
|
|
10443
|
+
method: "GET",
|
|
10444
|
+
path: "/api/v1/conversations/:conversationId/share-candidates",
|
|
10445
|
+
summary: "The members of the chat's workspace its creator may name, preselected or searched",
|
|
10446
|
+
tag: "Conversations",
|
|
10447
|
+
auth: "user",
|
|
10448
|
+
scope: "conversation:read",
|
|
10449
|
+
requires: [],
|
|
10450
|
+
effect: "reading",
|
|
10451
|
+
query: shareCandidatesQuerySchema,
|
|
10452
|
+
response: json(conversationShareCandidatesSchema),
|
|
10453
|
+
errors: ["NOT_FOUND", "FORBIDDEN"],
|
|
10454
|
+
rateClass: "read"
|
|
10455
|
+
}),
|
|
10288
10456
|
"conversations.thread.get": defineOperation({
|
|
10289
10457
|
id: "conversations.thread.get",
|
|
10290
10458
|
method: "GET",
|
|
@@ -11622,7 +11790,7 @@ var knowledgeStateResponseSchema = z57.object({
|
|
|
11622
11790
|
embedding: knowledgeEmbeddingStateSchema.optional(),
|
|
11623
11791
|
/**
|
|
11624
11792
|
* The formats this instance reads into a Knowledge Base that keeps documents: `txt` and
|
|
11625
|
-
* `markdown`, with document processing also `pdf` and `
|
|
11793
|
+
* `markdown`, with document processing also `pdf`, `docx`, `xlsx` and `pptx`. Omitted for a structured one.
|
|
11626
11794
|
*/
|
|
11627
11795
|
documentFormats: z57.array(z57.string()).optional(),
|
|
11628
11796
|
/** The id of the Knowledge Base's asset. */
|
|
@@ -11664,7 +11832,7 @@ var knowledgeListDocumentsResponseSchema = z57.object({
|
|
|
11664
11832
|
fileId: z57.string(),
|
|
11665
11833
|
fileName: z57.string(),
|
|
11666
11834
|
title: z57.string(),
|
|
11667
|
-
/** `txt`, `markdown`, `pdf` or `
|
|
11835
|
+
/** `txt`, `markdown`, `pdf`, `docx`, `xlsx` or `pptx`. */
|
|
11668
11836
|
format: z57.string(),
|
|
11669
11837
|
/** The size of the file in bytes. */
|
|
11670
11838
|
bytes: z57.number().int(),
|
|
@@ -11762,7 +11930,14 @@ var knowledgeSearchResponseSchema = z57.object({
|
|
|
11762
11930
|
text: z57.string(),
|
|
11763
11931
|
/** Reciprocal rank fusion of the lists in `signals`: compare it only within one Knowledge Base. */
|
|
11764
11932
|
score: z57.number(),
|
|
11765
|
-
originLink: z57.string().optional()
|
|
11933
|
+
originLink: z57.string().optional(),
|
|
11934
|
+
/**
|
|
11935
|
+
* The date a synced document states of its own version, such as the "Stand" of a web
|
|
11936
|
+
* page. An ISO date-time in UTC; none where the document states no date.
|
|
11937
|
+
*/
|
|
11938
|
+
statedAt: z57.string().optional(),
|
|
11939
|
+
/** When the platform fetched the synced version. An ISO date-time in UTC. */
|
|
11940
|
+
retrievedAt: z57.string().optional()
|
|
11766
11941
|
})
|
|
11767
11942
|
),
|
|
11768
11943
|
/** The ranked lists fused: `semantic`, `keyword` and `title`. */
|
|
@@ -14640,10 +14815,14 @@ function cliCompatibilityError(cliVersion, serverVersion) {
|
|
|
14640
14815
|
}
|
|
14641
14816
|
return cliVersion.split("+")[0] === serverVersion.split("+")[0] ? void 0 : new CliVersionError(cliVersion, serverVersion);
|
|
14642
14817
|
}
|
|
14818
|
+
function releaseVersionOf(serverVersion) {
|
|
14819
|
+
const release = serverVersion.split("+")[0] ?? "";
|
|
14820
|
+
return release.length <= 64 && versionParts(release) ? release : void 0;
|
|
14821
|
+
}
|
|
14643
14822
|
var CliVersionError = class extends Error {
|
|
14644
|
-
constructor(cliVersion, serverVersion) {
|
|
14823
|
+
constructor(cliVersion, serverVersion, instead) {
|
|
14645
14824
|
super(
|
|
14646
|
-
`Catalyst CLI ${cliVersion} does not match server ${serverVersion}; run: npm install --global @work-shape/catalyst-cli@${serverVersion.split("+")[0]}`
|
|
14825
|
+
`Catalyst CLI ${cliVersion} does not match server ${serverVersion}; ${instead ?? `run: npm install --global @work-shape/catalyst-cli@${serverVersion.split("+")[0]}`}`
|
|
14647
14826
|
);
|
|
14648
14827
|
this.cliVersion = cliVersion;
|
|
14649
14828
|
this.serverVersion = serverVersion;
|
|
@@ -14653,6 +14832,195 @@ var CliVersionError = class extends Error {
|
|
|
14653
14832
|
serverVersion;
|
|
14654
14833
|
};
|
|
14655
14834
|
|
|
14835
|
+
// src/self-update.ts
|
|
14836
|
+
import { spawnSync } from "child_process";
|
|
14837
|
+
import { existsSync, lstatSync, readFileSync, realpathSync } from "fs";
|
|
14838
|
+
import { posix, win32 } from "path";
|
|
14839
|
+
import { fileURLToPath } from "url";
|
|
14840
|
+
import { z as z70 } from "zod";
|
|
14841
|
+
|
|
14842
|
+
// src/env.ts
|
|
14843
|
+
function readConfigCliEnv(env) {
|
|
14844
|
+
return env ?? process.env;
|
|
14845
|
+
}
|
|
14846
|
+
function environmentUpdatedFrom(version) {
|
|
14847
|
+
return { ...process.env, CATALYST_CLI_UPDATED_FROM: version };
|
|
14848
|
+
}
|
|
14849
|
+
|
|
14850
|
+
// src/self-update.ts
|
|
14851
|
+
var PACKAGE = "@work-shape/catalyst-cli";
|
|
14852
|
+
var INSTALL_TIMEOUT_MS = 5 * 6e4;
|
|
14853
|
+
function isSet(value) {
|
|
14854
|
+
return value !== void 0 && value !== "" && value !== "0" && value.toLowerCase() !== "false";
|
|
14855
|
+
}
|
|
14856
|
+
function mayUpdateItself(env, interactive) {
|
|
14857
|
+
return interactive && !isSet(env.CATALYST_NO_AUTO_UPDATE) && !isSet(env.CI) && env.CATALYST_CLI_UPDATED_FROM === void 0;
|
|
14858
|
+
}
|
|
14859
|
+
function projectInstallation(host, version) {
|
|
14860
|
+
const path = host.platform === "win32" ? win32 : posix;
|
|
14861
|
+
const parts = host.packageRoot.split(path.sep);
|
|
14862
|
+
const first = parts.indexOf("node_modules");
|
|
14863
|
+
if (first <= 0 || parts.includes("_npx") || parts.includes("dlx")) return { kind: "elsewhere" };
|
|
14864
|
+
const spec = `${PACKAGE}@${version}`;
|
|
14865
|
+
if (parts[first - 2] === "global" && /^[0-9]+$/u.test(parts[first - 1] ?? "")) {
|
|
14866
|
+
return { kind: "pnpm-global", command: `pnpm add --global ${spec}` };
|
|
14867
|
+
}
|
|
14868
|
+
const folder = parts.slice(0, first).join(path.sep) || path.sep;
|
|
14869
|
+
if (!host.exists(path.join(folder, "package.json"))) return { kind: "elsewhere" };
|
|
14870
|
+
const command = host.exists(path.join(folder, "pnpm-lock.yaml")) ? `pnpm add --save-exact ${spec}` : host.exists(path.join(folder, "yarn.lock")) ? `yarn add --exact ${spec}` : `npm install --save-exact ${spec}`;
|
|
14871
|
+
return { kind: "project", folder, command };
|
|
14872
|
+
}
|
|
14873
|
+
function npmCommand(host) {
|
|
14874
|
+
const path = host.platform === "win32" ? win32 : posix;
|
|
14875
|
+
const bin = path.dirname(host.execPath);
|
|
14876
|
+
const script = [
|
|
14877
|
+
path.join(bin, "node_modules", "npm", "bin", "npm-cli.js"),
|
|
14878
|
+
path.join(bin, "..", "lib", "node_modules", "npm", "bin", "npm-cli.js")
|
|
14879
|
+
].find((candidate) => host.exists(candidate));
|
|
14880
|
+
if (script) return { file: host.execPath, args: [script] };
|
|
14881
|
+
return host.platform === "win32" ? void 0 : { file: "npm", args: [] };
|
|
14882
|
+
}
|
|
14883
|
+
function lastErrorLine(output) {
|
|
14884
|
+
const lines = output.split(/\r?\n/u).map((line2) => line2.trim()).filter(Boolean);
|
|
14885
|
+
const line = lines.find((entry) => /^npm (?:error|ERR!)/u.test(entry) && !/complete log/u.test(entry)) ?? lines.at(-1);
|
|
14886
|
+
return line === void 0 ? "npm gave no reason" : line.slice(0, 200);
|
|
14887
|
+
}
|
|
14888
|
+
var manifestSchema = z70.object({
|
|
14889
|
+
version: z70.string().optional(),
|
|
14890
|
+
bin: z70.object({ catalyst: z70.string().optional() }).optional()
|
|
14891
|
+
});
|
|
14892
|
+
function installedVersion(host) {
|
|
14893
|
+
const path = host.platform === "win32" ? win32 : posix;
|
|
14894
|
+
let parsed;
|
|
14895
|
+
try {
|
|
14896
|
+
parsed = JSON.parse(host.readText(path.join(host.packageRoot, "package.json")) ?? "{}");
|
|
14897
|
+
} catch {
|
|
14898
|
+
return {};
|
|
14899
|
+
}
|
|
14900
|
+
const manifest = manifestSchema.safeParse(parsed);
|
|
14901
|
+
if (!manifest.success) return {};
|
|
14902
|
+
return {
|
|
14903
|
+
...manifest.data.version === void 0 ? {} : { version: manifest.data.version },
|
|
14904
|
+
...manifest.data.bin?.catalyst === void 0 ? {} : { bin: manifest.data.bin.catalyst }
|
|
14905
|
+
};
|
|
14906
|
+
}
|
|
14907
|
+
function updateToServerVersion(mismatch, host) {
|
|
14908
|
+
const version = releaseVersionOf(mismatch.serverVersion);
|
|
14909
|
+
if (version === void 0) return mismatch;
|
|
14910
|
+
const project = projectInstallation(host, version);
|
|
14911
|
+
if (project.kind !== "elsewhere") {
|
|
14912
|
+
return new CliVersionError(
|
|
14913
|
+
mismatch.cliVersion,
|
|
14914
|
+
mismatch.serverVersion,
|
|
14915
|
+
project.kind === "project" ? `in ${project.folder} run: ${project.command}` : `run: ${project.command}`
|
|
14916
|
+
);
|
|
14917
|
+
}
|
|
14918
|
+
if (!older(mismatch.cliVersion, version)) return mismatch;
|
|
14919
|
+
if (!mayUpdateItself(host.env, host.interactive)) return mismatch;
|
|
14920
|
+
const npm = npmCommand(host);
|
|
14921
|
+
if (npm === void 0) return mismatch;
|
|
14922
|
+
const path = host.platform === "win32" ? win32 : posix;
|
|
14923
|
+
const root = host.run(npm.file, [...npm.args, "root", "--global"], {});
|
|
14924
|
+
const globalRoot = root.status === 0 ? root.stdout.trim() : "";
|
|
14925
|
+
const globalPackage = path.join(globalRoot, ...PACKAGE.split("/"));
|
|
14926
|
+
let ours;
|
|
14927
|
+
try {
|
|
14928
|
+
ours = globalRoot !== "" && !host.isLink(globalPackage) && host.realpath(globalPackage) === host.realpath(host.packageRoot);
|
|
14929
|
+
} catch {
|
|
14930
|
+
ours = false;
|
|
14931
|
+
}
|
|
14932
|
+
if (!ours) return mismatch;
|
|
14933
|
+
host.stderr(
|
|
14934
|
+
`The instance runs ${version}; installing ${PACKAGE}@${version} in place of ${mismatch.cliVersion} and running the command again.
|
|
14935
|
+
`
|
|
14936
|
+
);
|
|
14937
|
+
const install = host.run(
|
|
14938
|
+
npm.file,
|
|
14939
|
+
[
|
|
14940
|
+
...npm.args,
|
|
14941
|
+
"install",
|
|
14942
|
+
"--global",
|
|
14943
|
+
"--no-fund",
|
|
14944
|
+
"--no-audit",
|
|
14945
|
+
"--loglevel=error",
|
|
14946
|
+
`${PACKAGE}@${version}`
|
|
14947
|
+
],
|
|
14948
|
+
{}
|
|
14949
|
+
);
|
|
14950
|
+
const installed = installedVersion(host);
|
|
14951
|
+
if (install.status !== 0 || installed.version !== version) {
|
|
14952
|
+
host.stderr(
|
|
14953
|
+
`Could not install ${PACKAGE}@${version}: ${lastErrorLine(`${install.stdout}
|
|
14954
|
+
${install.stderr}`)}
|
|
14955
|
+
`
|
|
14956
|
+
);
|
|
14957
|
+
return mismatch;
|
|
14958
|
+
}
|
|
14959
|
+
const entry = path.resolve(host.packageRoot, installed.bin ?? "dist/index.js");
|
|
14960
|
+
if (!entry.startsWith(host.packageRoot + path.sep)) return mismatch;
|
|
14961
|
+
const again = host.run(host.execPath, [entry, ...host.argv], {
|
|
14962
|
+
againFrom: mismatch.cliVersion
|
|
14963
|
+
});
|
|
14964
|
+
return host.exit(again.status ?? 1);
|
|
14965
|
+
}
|
|
14966
|
+
var state;
|
|
14967
|
+
function onInstanceAnswer() {
|
|
14968
|
+
if (state) state.answered = true;
|
|
14969
|
+
}
|
|
14970
|
+
function onCliVersionMismatch(mismatch) {
|
|
14971
|
+
const active = state;
|
|
14972
|
+
if (active === void 0 || active.answered) return Promise.resolve(mismatch);
|
|
14973
|
+
active.attempt ??= Promise.resolve().then(() => updateToServerVersion(mismatch, active.host));
|
|
14974
|
+
return active.attempt;
|
|
14975
|
+
}
|
|
14976
|
+
function enableSelfUpdate(argv, host = processHost(argv)) {
|
|
14977
|
+
const enabled = { host, answered: false };
|
|
14978
|
+
state = enabled;
|
|
14979
|
+
return () => {
|
|
14980
|
+
if (state === enabled) state = void 0;
|
|
14981
|
+
};
|
|
14982
|
+
}
|
|
14983
|
+
function processHost(argv) {
|
|
14984
|
+
return {
|
|
14985
|
+
argv,
|
|
14986
|
+
env: readConfigCliEnv(),
|
|
14987
|
+
interactive: process.stdin.isTTY === true && process.stderr.isTTY === true,
|
|
14988
|
+
platform: process.platform,
|
|
14989
|
+
execPath: process.execPath,
|
|
14990
|
+
packageRoot: realpathSync(fileURLToPath(new URL("..", import.meta.url))).replace(/[\\/]$/u, ""),
|
|
14991
|
+
exists: existsSync,
|
|
14992
|
+
readText: (path) => {
|
|
14993
|
+
try {
|
|
14994
|
+
return readFileSync(path, "utf8");
|
|
14995
|
+
} catch {
|
|
14996
|
+
return void 0;
|
|
14997
|
+
}
|
|
14998
|
+
},
|
|
14999
|
+
realpath: realpathSync,
|
|
15000
|
+
isLink: (path) => {
|
|
15001
|
+
try {
|
|
15002
|
+
return lstatSync(path).isSymbolicLink();
|
|
15003
|
+
} catch {
|
|
15004
|
+
return false;
|
|
15005
|
+
}
|
|
15006
|
+
},
|
|
15007
|
+
run: (file, args, options) => {
|
|
15008
|
+
const result = spawnSync(file, args, {
|
|
15009
|
+
shell: false,
|
|
15010
|
+
windowsHide: true,
|
|
15011
|
+
...options.againFrom !== void 0 ? { stdio: "inherit", env: environmentUpdatedFrom(options.againFrom) } : { encoding: "utf8", timeout: INSTALL_TIMEOUT_MS, maxBuffer: 16 * 1024 * 1024 }
|
|
15012
|
+
});
|
|
15013
|
+
return {
|
|
15014
|
+
status: result.status,
|
|
15015
|
+
stdout: typeof result.stdout === "string" ? result.stdout : "",
|
|
15016
|
+
stderr: typeof result.stderr === "string" ? result.stderr : ""
|
|
15017
|
+
};
|
|
15018
|
+
},
|
|
15019
|
+
stderr: (text2) => process.stderr.write(text2),
|
|
15020
|
+
exit: (code) => process.exit(code)
|
|
15021
|
+
};
|
|
15022
|
+
}
|
|
15023
|
+
|
|
14656
15024
|
// src/api.ts
|
|
14657
15025
|
var ConfigApiError = class extends Error {
|
|
14658
15026
|
status;
|
|
@@ -14847,9 +15215,10 @@ function instanceFetch(fetchImpl, diagnostics = {}) {
|
|
|
14847
15215
|
const mismatch = cliCompatibilityError(RELEASE_VERSION, serverVersion);
|
|
14848
15216
|
if (diagnostics.checkVersion !== false && mismatch) {
|
|
14849
15217
|
await response.body?.cancel();
|
|
14850
|
-
throw mismatch;
|
|
15218
|
+
throw mismatch instanceof CliVersionError ? await onCliVersionMismatch(mismatch) : mismatch;
|
|
14851
15219
|
}
|
|
14852
15220
|
}
|
|
15221
|
+
onInstanceAnswer();
|
|
14853
15222
|
return response;
|
|
14854
15223
|
};
|
|
14855
15224
|
}
|
|
@@ -14963,9 +15332,9 @@ async function readFolderState(directory, filename, kind) {
|
|
|
14963
15332
|
name: name2
|
|
14964
15333
|
};
|
|
14965
15334
|
}
|
|
14966
|
-
async function writeFolderState(directory, filename,
|
|
15335
|
+
async function writeFolderState(directory, filename, state2) {
|
|
14967
15336
|
const path = join(directory, filename);
|
|
14968
|
-
await writeFile(`${path}.tmp`, `${JSON.stringify(
|
|
15337
|
+
await writeFile(`${path}.tmp`, `${JSON.stringify(state2, null, 2)}
|
|
14969
15338
|
`, { mode: 420 });
|
|
14970
15339
|
await rename(`${path}.tmp`, path);
|
|
14971
15340
|
}
|
|
@@ -14983,13 +15352,13 @@ async function refuseLinks(directory, recursive = true) {
|
|
|
14983
15352
|
for (const entry of await readdir(directory)) await refuseLinks(join(directory, entry));
|
|
14984
15353
|
}
|
|
14985
15354
|
}
|
|
14986
|
-
async function localChanges(directory,
|
|
15355
|
+
async function localChanges(directory, state2, filename, ignoreUntracked = false) {
|
|
14987
15356
|
const now = {};
|
|
14988
15357
|
const walk2 = async (folder, prefix) => {
|
|
14989
15358
|
for (const entry of await readdir(folder, { withFileTypes: true })) {
|
|
14990
15359
|
const path = `${prefix}${entry.name}`;
|
|
14991
15360
|
if (path === filename || entry.name === ".DS_Store" && entry.isFile()) continue;
|
|
14992
|
-
const tracked = Object.hasOwn(
|
|
15361
|
+
const tracked = Object.hasOwn(state2.files, path) || Object.keys(state2.files).some((file) => file.startsWith(`${path}/`));
|
|
14993
15362
|
if (ignoreUntracked && !tracked && (entry.name.startsWith(".") || entry.isDirectory() && entry.name === "node_modules"))
|
|
14994
15363
|
continue;
|
|
14995
15364
|
if (entry.isDirectory()) await walk2(join(folder, entry.name), `${path}/`);
|
|
@@ -15003,10 +15372,10 @@ async function localChanges(directory, state, filename, ignoreUntracked = false)
|
|
|
15003
15372
|
await walk2(directory, "");
|
|
15004
15373
|
return {
|
|
15005
15374
|
changed: Object.keys(now).filter(
|
|
15006
|
-
(path) => Object.hasOwn(
|
|
15375
|
+
(path) => Object.hasOwn(state2.files, path) && now[path] !== state2.files[path]
|
|
15007
15376
|
),
|
|
15008
|
-
added: Object.keys(now).filter((path) => !Object.hasOwn(
|
|
15009
|
-
removed: Object.keys(
|
|
15377
|
+
added: Object.keys(now).filter((path) => !Object.hasOwn(state2.files, path)),
|
|
15378
|
+
removed: Object.keys(state2.files).filter(
|
|
15010
15379
|
(path) => basename(path) !== ".DS_Store" && !Object.hasOwn(now, path)
|
|
15011
15380
|
)
|
|
15012
15381
|
};
|
|
@@ -15031,7 +15400,7 @@ async function writeFolderFiles(directory, files, previous) {
|
|
|
15031
15400
|
}
|
|
15032
15401
|
return hashes;
|
|
15033
15402
|
}
|
|
15034
|
-
async function replaceFolder(directory, files, filename,
|
|
15403
|
+
async function replaceFolder(directory, files, filename, state2, beforeReplace) {
|
|
15035
15404
|
const createdParent = await mkdir(dirname(directory), { recursive: true });
|
|
15036
15405
|
let temporary;
|
|
15037
15406
|
let installed = false;
|
|
@@ -15044,7 +15413,7 @@ async function replaceFolder(directory, files, filename, state, beforeReplace) {
|
|
|
15044
15413
|
if (files.some((file) => file.path === filename))
|
|
15045
15414
|
throw new Error(`The instance named the reserved state file '${filename}'.`);
|
|
15046
15415
|
const hashes = await writeFolderFiles(staged, files);
|
|
15047
|
-
await writeFolderState(staged, filename, { ...
|
|
15416
|
+
await writeFolderState(staged, filename, { ...state2, files: hashes });
|
|
15048
15417
|
await beforeReplace();
|
|
15049
15418
|
try {
|
|
15050
15419
|
await rename(directory, backup);
|
|
@@ -15270,11 +15639,6 @@ function isCredentialFile(value) {
|
|
|
15270
15639
|
);
|
|
15271
15640
|
}
|
|
15272
15641
|
|
|
15273
|
-
// src/env.ts
|
|
15274
|
-
function readConfigCliEnv(env) {
|
|
15275
|
-
return env ?? process.env;
|
|
15276
|
-
}
|
|
15277
|
-
|
|
15278
15642
|
// src/guardrail-files.ts
|
|
15279
15643
|
import { readFile as readFile4, stat as stat2 } from "fs/promises";
|
|
15280
15644
|
import { join as join4 } from "path";
|
|
@@ -15591,10 +15955,10 @@ function readBaselineHashes(input) {
|
|
|
15591
15955
|
})
|
|
15592
15956
|
);
|
|
15593
15957
|
}
|
|
15594
|
-
async function writeStateFile(path,
|
|
15958
|
+
async function writeStateFile(path, state2) {
|
|
15595
15959
|
await mkdir3(dirname3(path), { recursive: true });
|
|
15596
15960
|
const temporaryPath = `${path}.${process.pid}.tmp`;
|
|
15597
|
-
await writeFile3(temporaryPath, `${JSON.stringify(
|
|
15961
|
+
await writeFile3(temporaryPath, `${JSON.stringify(state2, null, 2)}
|
|
15598
15962
|
`, "utf8");
|
|
15599
15963
|
await rename3(temporaryPath, path);
|
|
15600
15964
|
}
|
|
@@ -16282,8 +16646,8 @@ async function openInstance(options) {
|
|
|
16282
16646
|
}
|
|
16283
16647
|
async function recordBaseline(workingDir, instanceKey, version, bundle, revisions, fullPull, defaultAgentName, tombstones = {}) {
|
|
16284
16648
|
const path = resolve4(workingDir, STATE_FILENAME);
|
|
16285
|
-
const
|
|
16286
|
-
const previous =
|
|
16649
|
+
const state2 = await readStateFile(path);
|
|
16650
|
+
const previous = state2.instances[instanceKey];
|
|
16287
16651
|
const baseline = {
|
|
16288
16652
|
...previous,
|
|
16289
16653
|
lastPulledVersion: fullPull ? version : previous?.lastPulledVersion ?? version
|
|
@@ -16320,7 +16684,7 @@ async function recordBaseline(workingDir, instanceKey, version, bundle, revision
|
|
|
16320
16684
|
if (defaultAgentName !== void 0) {
|
|
16321
16685
|
baseline.defaultAgentName = defaultAgentName;
|
|
16322
16686
|
}
|
|
16323
|
-
await writeStateFile(path, { instances: { ...
|
|
16687
|
+
await writeStateFile(path, { instances: { ...state2.instances, [instanceKey]: baseline } });
|
|
16324
16688
|
}
|
|
16325
16689
|
function resolveWorkingDir(options) {
|
|
16326
16690
|
return resolve4(options.cwd, options.dir ?? ".");
|
|
@@ -16737,18 +17101,18 @@ var REPOSITORY_KINDS = {
|
|
|
16737
17101
|
}
|
|
16738
17102
|
};
|
|
16739
17103
|
async function readRepositoryState(directory, kind) {
|
|
16740
|
-
const
|
|
16741
|
-
if (
|
|
16742
|
-
return
|
|
17104
|
+
const state2 = await readFolderState(directory, APP_STATE_FILE, kind.kind);
|
|
17105
|
+
if (state2 === void 0) return void 0;
|
|
17106
|
+
return state2;
|
|
16743
17107
|
}
|
|
16744
|
-
async function writeRepositoryState(directory,
|
|
17108
|
+
async function writeRepositoryState(directory, state2, kind) {
|
|
16745
17109
|
await writeFolderState(directory, APP_STATE_FILE, {
|
|
16746
|
-
instance:
|
|
16747
|
-
workspaceId:
|
|
16748
|
-
[kind.kind]:
|
|
16749
|
-
assetId:
|
|
16750
|
-
revision:
|
|
16751
|
-
files:
|
|
17110
|
+
instance: state2.instance,
|
|
17111
|
+
workspaceId: state2.workspaceId,
|
|
17112
|
+
[kind.kind]: state2.name,
|
|
17113
|
+
assetId: state2.assetId,
|
|
17114
|
+
revision: state2.revision,
|
|
17115
|
+
files: state2.files
|
|
16752
17116
|
});
|
|
16753
17117
|
}
|
|
16754
17118
|
async function readRepositoryFolder(directory, limits, tracked, kind) {
|
|
@@ -16822,8 +17186,8 @@ async function walk(root, directory, tracked, found, leftOut) {
|
|
|
16822
17186
|
}
|
|
16823
17187
|
}
|
|
16824
17188
|
}
|
|
16825
|
-
async function localChanges2(directory,
|
|
16826
|
-
return localChanges(directory,
|
|
17189
|
+
async function localChanges2(directory, state2) {
|
|
17190
|
+
return localChanges(directory, state2, APP_STATE_FILE, true);
|
|
16827
17191
|
}
|
|
16828
17192
|
function utf8Text2(bytes) {
|
|
16829
17193
|
try {
|
|
@@ -16903,6 +17267,19 @@ function formatAssetList(kind, assets) {
|
|
|
16903
17267
|
])
|
|
16904
17268
|
);
|
|
16905
17269
|
}
|
|
17270
|
+
function availabilityPhrase(availability) {
|
|
17271
|
+
const personal = availability.personalWorkspaces ? ["personal workspaces"] : [];
|
|
17272
|
+
switch (availability.mode) {
|
|
17273
|
+
case "all":
|
|
17274
|
+
return "every workspace";
|
|
17275
|
+
case "all_except":
|
|
17276
|
+
return `every ${availability.personalWorkspaces ? "" : "shared "}workspace except ${list(
|
|
17277
|
+
availability.collaborationWorkspaceIds
|
|
17278
|
+
)}`;
|
|
17279
|
+
case "selected":
|
|
17280
|
+
return list([...personal, ...availability.collaborationWorkspaceIds]);
|
|
17281
|
+
}
|
|
17282
|
+
}
|
|
16906
17283
|
function formatAsset(asset) {
|
|
16907
17284
|
const facts = [
|
|
16908
17285
|
["kind", asset.kind],
|
|
@@ -16914,13 +17291,7 @@ function formatAsset(asset) {
|
|
|
16914
17291
|
["content of revision", asset.contentRevision?.toString()],
|
|
16915
17292
|
["scope", scopeLabel(asset.scope)],
|
|
16916
17293
|
["default", asset.isDefault ? "yes" : void 0],
|
|
16917
|
-
[
|
|
16918
|
-
"available in",
|
|
16919
|
-
asset.availability && (asset.availability.mode === "all" ? "every workspace" : list([
|
|
16920
|
-
...asset.availability.personalWorkspaces ? ["personal workspaces"] : [],
|
|
16921
|
-
...asset.availability.collaborationWorkspaceIds
|
|
16922
|
-
]))
|
|
16923
|
-
],
|
|
17294
|
+
["available in", asset.availability && availabilityPhrase(asset.availability)],
|
|
16924
17295
|
["updated", asset.updatedAt]
|
|
16925
17296
|
];
|
|
16926
17297
|
const lines = facts.flatMap(
|
|
@@ -17039,12 +17410,19 @@ async function askBeforePublish(options, publish2) {
|
|
|
17039
17410
|
writeError(options, "Nothing was published.");
|
|
17040
17411
|
return "refused";
|
|
17041
17412
|
}
|
|
17042
|
-
|
|
17413
|
+
var OVERTAKEN_LINE = "If another version goes live before it is decided, this request is settled as superseded: it can do nothing then and never overwrites that version.";
|
|
17414
|
+
function isAlreadyLive(error) {
|
|
17415
|
+
return error instanceof ConfigApiError && error.status === 409 && isRecord(error.details) && error.details.reason === "already_live";
|
|
17416
|
+
}
|
|
17417
|
+
function alreadyLiveLine(kind, name2, revision) {
|
|
17418
|
+
return `Revision ${revision} of ${kind} '${name2}' is already live. Nothing to do: nothing was published and no request was filed.`;
|
|
17419
|
+
}
|
|
17420
|
+
function waitingPublishLine(run, approvalHint, note) {
|
|
17043
17421
|
const named = `${run.approvalRequestId === void 0 ? "" : `request ${run.approvalRequestId}, `}Operation Run ${run.id}`;
|
|
17044
17422
|
if (run.status === "pending_confirmation") {
|
|
17045
|
-
return `Waits in your Inbox for your confirmation; nothing has changed yet (${named}). Allow it there to publish, or deny it
|
|
17423
|
+
return `Waits in your Inbox for your confirmation; nothing has changed yet (${named}). Allow it there to publish, or deny it.${note ? ` ${note}` : ""}`;
|
|
17046
17424
|
}
|
|
17047
|
-
return `Waits for an approval on the instance; nothing has changed yet (${named}).${approvalHint ? ` ${approvalHint}` : ""}`;
|
|
17425
|
+
return `Waits for an approval on the instance; nothing has changed yet (${named}).${approvalHint ? ` ${approvalHint}` : ""}${note ? ` ${note}` : ""}`;
|
|
17048
17426
|
}
|
|
17049
17427
|
function agentPublishRefusalHint(error) {
|
|
17050
17428
|
if (!(error instanceof ConfigApiError) || error.status !== 403) return void 0;
|
|
@@ -17193,8 +17571,8 @@ async function pull(app, directory, values, options, kind) {
|
|
|
17193
17571
|
return EXIT.done;
|
|
17194
17572
|
}
|
|
17195
17573
|
async function push(directory, values, options, kind) {
|
|
17196
|
-
const
|
|
17197
|
-
const target = await openRepository(options, values,
|
|
17574
|
+
const state2 = await readRepositoryState(directory, kind);
|
|
17575
|
+
const target = await openRepository(options, values, state2, kind);
|
|
17198
17576
|
const registered = target.kinds.find((candidate) => candidate.kind === kind.kind);
|
|
17199
17577
|
if (registered === void 0) {
|
|
17200
17578
|
throw new Error(
|
|
@@ -17204,44 +17582,44 @@ async function push(directory, values, options, kind) {
|
|
|
17204
17582
|
const read2 = await readRepositoryFolder(
|
|
17205
17583
|
directory,
|
|
17206
17584
|
registered.limits,
|
|
17207
|
-
new Set(Object.keys(
|
|
17585
|
+
new Set(Object.keys(state2?.files ?? {})),
|
|
17208
17586
|
kind
|
|
17209
17587
|
);
|
|
17210
|
-
const name2 =
|
|
17211
|
-
if (
|
|
17588
|
+
const name2 = state2?.name ?? repositoryIdOf(read2.files, kind);
|
|
17589
|
+
if (state2 === void 0 && name2 === void 0) {
|
|
17212
17590
|
throw new RepositoryUsageError(
|
|
17213
17591
|
`${kind.manifest} names no \`id\`. The id is the ${kind.label}'s name on the instance: add \`id: <name>\` to ${kind.manifest}.`
|
|
17214
17592
|
);
|
|
17215
17593
|
}
|
|
17216
17594
|
const app = name2 ?? "";
|
|
17217
|
-
const declared =
|
|
17218
|
-
if (
|
|
17595
|
+
const declared = state2 === void 0 ? void 0 : declaredIdOf(read2.files, kind);
|
|
17596
|
+
if (state2 !== void 0 && declared !== void 0 && declared !== state2.name) {
|
|
17219
17597
|
throw new RepositoryUsageError(
|
|
17220
|
-
`${kind.manifest} names the id '${declared}', and '${directory}' holds the ${kind.label} '${
|
|
17598
|
+
`${kind.manifest} names the id '${declared}', and '${directory}' holds the ${kind.label} '${state2.name}'. ${kind.article} ${kind.label} keeps its id: set \`id: ${state2.name}\` again, or copy the files without ${APP_STATE_FILE} into a new folder to create the ${kind.label} '${declared}'.`
|
|
17221
17599
|
);
|
|
17222
17600
|
}
|
|
17223
|
-
const expectedRevision =
|
|
17224
|
-
if (
|
|
17601
|
+
const expectedRevision = state2?.revision ?? null;
|
|
17602
|
+
if (state2 !== void 0 && state2.workspaceId !== target.workspaceId) {
|
|
17225
17603
|
throw new RepositoryUsageError(
|
|
17226
|
-
`'${directory}' was pulled from workspace ${
|
|
17604
|
+
`'${directory}' was pulled from workspace ${state2.workspaceId}, and the command names ${target.workspaceId}.`
|
|
17227
17605
|
);
|
|
17228
17606
|
}
|
|
17229
|
-
if (kind.kind === "workflow" &&
|
|
17607
|
+
if (kind.kind === "workflow" && state2 !== void 0 && Object.keys(read2.hashes).length === Object.keys(state2.files).length && Object.entries(read2.hashes).every(([path, hash2]) => state2.files[path] === hash2)) {
|
|
17230
17608
|
const current = await target.api.read(
|
|
17231
17609
|
(client) => client.assets.get({
|
|
17232
17610
|
params: { kind: kind.kind, name: app },
|
|
17233
17611
|
query: { workspaceId: target.workspaceId }
|
|
17234
17612
|
})
|
|
17235
17613
|
);
|
|
17236
|
-
if ((current.draftRevision ?? current.revision) ===
|
|
17614
|
+
if ((current.draftRevision ?? current.revision) === state2.revision) {
|
|
17237
17615
|
writeOut(
|
|
17238
17616
|
options,
|
|
17239
17617
|
values.json ? JSON.stringify(
|
|
17240
|
-
{ revision:
|
|
17618
|
+
{ revision: state2.revision, unchanged: true, leftOut: read2.leftOut },
|
|
17241
17619
|
null,
|
|
17242
17620
|
2
|
|
17243
17621
|
) : [
|
|
17244
|
-
`Unchanged ${kind.label} '${app}' at draft revision ${
|
|
17622
|
+
`Unchanged ${kind.label} '${app}' at draft revision ${state2.revision}.`,
|
|
17245
17623
|
...read2.leftOut.length === 0 ? [] : [`Left out: ${read2.leftOut.join(", ")}`]
|
|
17246
17624
|
].join("\n")
|
|
17247
17625
|
);
|
|
@@ -17411,7 +17789,8 @@ async function publish(app, values, options) {
|
|
|
17411
17789
|
outcome.run,
|
|
17412
17790
|
values.json,
|
|
17413
17791
|
options,
|
|
17414
|
-
"If you are an instance approver, you can approve it in the Inbox."
|
|
17792
|
+
"If you are an instance approver, you can approve it in the Inbox.",
|
|
17793
|
+
OVERTAKEN_LINE
|
|
17415
17794
|
);
|
|
17416
17795
|
}
|
|
17417
17796
|
writeOut(
|
|
@@ -17430,18 +17809,18 @@ function startsWorkflows(config) {
|
|
|
17430
17809
|
return Array.isArray(manifest?.actions) && manifest.actions.some((action) => isRecord(action) && action.kind === "workflow");
|
|
17431
17810
|
}
|
|
17432
17811
|
async function status(app, directory, values, options, kind) {
|
|
17433
|
-
const
|
|
17434
|
-
if (directory !== void 0 &&
|
|
17812
|
+
const state2 = directory === void 0 ? void 0 : await readRepositoryState(directory, kind);
|
|
17813
|
+
if (directory !== void 0 && state2 === void 0) {
|
|
17435
17814
|
throw new RepositoryUsageError(
|
|
17436
17815
|
`'${directory}' holds no pulled ${kind.label} (no ${APP_STATE_FILE}).`
|
|
17437
17816
|
);
|
|
17438
17817
|
}
|
|
17439
|
-
if (
|
|
17818
|
+
if (state2 !== void 0 && state2.name !== app) {
|
|
17440
17819
|
throw new RepositoryUsageError(
|
|
17441
|
-
`'${directory}' holds the ${kind.label} '${
|
|
17820
|
+
`'${directory}' holds the ${kind.label} '${state2.name}', not '${app}'.`
|
|
17442
17821
|
);
|
|
17443
17822
|
}
|
|
17444
|
-
const target = await openRepository(options, values,
|
|
17823
|
+
const target = await openRepository(options, values, state2, kind);
|
|
17445
17824
|
const asset = await target.api.read(
|
|
17446
17825
|
(client) => client.assets.get({
|
|
17447
17826
|
params: { kind: kind.kind, name: app },
|
|
@@ -17457,7 +17836,7 @@ async function status(app, directory, values, options, kind) {
|
|
|
17457
17836
|
kind
|
|
17458
17837
|
);
|
|
17459
17838
|
const by = (revision) => revisions.find((entry) => entry.revision === revision);
|
|
17460
|
-
const local = directory === void 0 ||
|
|
17839
|
+
const local = directory === void 0 || state2 === void 0 ? void 0 : { directory, base: state2.revision, ...await localChanges2(directory, state2) };
|
|
17461
17840
|
const report = {
|
|
17462
17841
|
[kind.kind]: app,
|
|
17463
17842
|
workspaceId: target.workspaceId,
|
|
@@ -17559,19 +17938,19 @@ function formatReview(app, review) {
|
|
|
17559
17938
|
)
|
|
17560
17939
|
].join("\n");
|
|
17561
17940
|
}
|
|
17562
|
-
async function openRepository(options, values,
|
|
17941
|
+
async function openRepository(options, values, state2, kind) {
|
|
17563
17942
|
const manifest = await readManifestIfPresent(resolveWorkingDir(options));
|
|
17564
17943
|
const instance = await resolveInstance(manifest, {
|
|
17565
17944
|
...options,
|
|
17566
|
-
...options.instance === void 0 && manifest?.defaultInstance === void 0 &&
|
|
17945
|
+
...options.instance === void 0 && manifest?.defaultInstance === void 0 && state2 ? { instance: state2.instance } : {}
|
|
17567
17946
|
});
|
|
17568
17947
|
const { url } = instance;
|
|
17569
|
-
if (
|
|
17948
|
+
if (state2 !== void 0 && state2.instance !== url) {
|
|
17570
17949
|
throw new RepositoryUsageError(
|
|
17571
|
-
`The folder was pulled from ${
|
|
17950
|
+
`The folder was pulled from ${state2.instance}, and the command names ${url}. A folder belongs to one instance.`
|
|
17572
17951
|
);
|
|
17573
17952
|
}
|
|
17574
|
-
const workspaceId = values.workspace ??
|
|
17953
|
+
const workspaceId = values.workspace ?? state2?.workspaceId ?? instance.workspace;
|
|
17575
17954
|
if (workspaceId === void 0) {
|
|
17576
17955
|
throw new RepositoryUsageError(
|
|
17577
17956
|
`Name the workspace the ${kind.label} belongs to: --workspace <id>, or \`workspace: <id>\` in catalyst.yaml.`
|
|
@@ -17658,9 +18037,9 @@ function writeErr(target, text2) {
|
|
|
17658
18037
|
(target.stderr ?? ((value) => process.stderr.write(value)))(`${text2}
|
|
17659
18038
|
`);
|
|
17660
18039
|
}
|
|
17661
|
-
function pendingApproval(run, json2, options, hint) {
|
|
18040
|
+
function pendingApproval(run, json2, options, hint, note) {
|
|
17662
18041
|
if (json2) writeOut(options, JSON.stringify({ status: "pending_approval", run }, null, 2));
|
|
17663
|
-
else writeErr(options, waitingPublishLine(run, hint));
|
|
18042
|
+
else writeErr(options, waitingPublishLine(run, hint, note));
|
|
17664
18043
|
return EXIT.pending;
|
|
17665
18044
|
}
|
|
17666
18045
|
function readAudience(value) {
|
|
@@ -17721,7 +18100,7 @@ async function runFollowCommand(api, command, input, options) {
|
|
|
17721
18100
|
() => [
|
|
17722
18101
|
"ID STATUS SUMMARY DECISION",
|
|
17723
18102
|
...items.map(
|
|
17724
|
-
(request) => `${request.id} ${request.status} ${request.summary} ${request.decision?.decidedByLabel ?? ""}${request.decision?.comment ? `: ${request.decision.comment}` : ""}`
|
|
18103
|
+
(request) => `${request.id} ${request.status} ${request.summary} ${request.decision?.decidedByLabel ?? ""}${request.decision?.comment ? `: ${request.decision.comment}` : ""}${request.status === "superseded" ? ` ${supersededLine(request)}` : ""}`
|
|
17725
18104
|
)
|
|
17726
18105
|
].join("\n")
|
|
17727
18106
|
);
|
|
@@ -17729,6 +18108,12 @@ async function runFollowCommand(api, command, input, options) {
|
|
|
17729
18108
|
}
|
|
17730
18109
|
return EXIT2.done;
|
|
17731
18110
|
}
|
|
18111
|
+
function supersededLine(request) {
|
|
18112
|
+
const result = request.applyResult;
|
|
18113
|
+
const error = typeof result === "object" && result !== null && "error" in result ? result.error : void 0;
|
|
18114
|
+
const reason = typeof error === "object" && error !== null && "message" in error && typeof error.message === "string" ? ` ${error.message}` : "";
|
|
18115
|
+
return `Settled without a decision: it can do nothing, nothing of it ran or will run.${reason}`;
|
|
18116
|
+
}
|
|
17732
18117
|
|
|
17733
18118
|
// src/asset-help.ts
|
|
17734
18119
|
function formatAssetHelp(verbs) {
|
|
@@ -17848,8 +18233,8 @@ async function pushConfig(options) {
|
|
|
17848
18233
|
if (options.force) {
|
|
17849
18234
|
throw new Error(FORCE_REFUSED_MESSAGE);
|
|
17850
18235
|
}
|
|
17851
|
-
const
|
|
17852
|
-
const baseline =
|
|
18236
|
+
const state2 = await readStateFile(resolve6(workingDir, STATE_FILENAME));
|
|
18237
|
+
const baseline = state2.instances[instance.key] ?? {
|
|
17853
18238
|
lastPulledVersion: 0,
|
|
17854
18239
|
assets: {},
|
|
17855
18240
|
defaultAgentName: null
|
|
@@ -18273,7 +18658,10 @@ async function publishDrafts(api, drafts, input) {
|
|
|
18273
18658
|
return 1;
|
|
18274
18659
|
}
|
|
18275
18660
|
if (outcome.status === "pending_approval") {
|
|
18276
|
-
writeError(
|
|
18661
|
+
writeError(
|
|
18662
|
+
options,
|
|
18663
|
+
`${draft.key}: ${waitingPublishLine(outcome.run, void 0, OVERTAKEN_LINE)}`
|
|
18664
|
+
);
|
|
18277
18665
|
unpublished(index + 1);
|
|
18278
18666
|
return 3;
|
|
18279
18667
|
}
|
|
@@ -18659,9 +19047,9 @@ function filesRead(session2, from, files) {
|
|
|
18659
19047
|
].join("\n")
|
|
18660
19048
|
);
|
|
18661
19049
|
}
|
|
18662
|
-
function settle(session2, outcome, lines, approvalHint) {
|
|
19050
|
+
function settle(session2, outcome, lines, approvalHint, waitingNote) {
|
|
18663
19051
|
if (outcome.status === "pending_approval") {
|
|
18664
|
-
const text2 = waitingPublishLine(outcome.run, approvalHint);
|
|
19052
|
+
const text2 = waitingPublishLine(outcome.run, approvalHint, waitingNote);
|
|
18665
19053
|
if (session2.values.json)
|
|
18666
19054
|
writeOutput(
|
|
18667
19055
|
session2.options,
|
|
@@ -19240,6 +19628,7 @@ async function guardrailDryRunBeforePublish(session2, name2, revision) {
|
|
|
19240
19628
|
}
|
|
19241
19629
|
|
|
19242
19630
|
// src/asset-verbs/publish.ts
|
|
19631
|
+
var ALREADY_LIVE = /* @__PURE__ */ Symbol("already live");
|
|
19243
19632
|
var publishVerb = {
|
|
19244
19633
|
usage: "publish <name> --revision <n> [--yes] [--confirm <blocked>]",
|
|
19245
19634
|
summary: "Make one revision the one its users are served (assets.publish). A guardrail shows its dry run first; an App, a Workflow or a workspace's agent asks you first. A publish that hands a source's data to people who may not use the source waits in the Inbox until a person who may change the source approves it",
|
|
@@ -19316,10 +19705,21 @@ var publishVerb = {
|
|
|
19316
19705
|
}),
|
|
19317
19706
|
"It may have been applied: run 'show' before sending it again."
|
|
19318
19707
|
).catch((error) => {
|
|
19708
|
+
if (isAlreadyLive(error)) return ALREADY_LIVE;
|
|
19319
19709
|
const hint = agent ? agentPublishRefusalHint(error) : void 0;
|
|
19320
19710
|
if (hint === void 0) throw error;
|
|
19321
19711
|
throw new ExplainedRefusal(error, hint);
|
|
19322
19712
|
});
|
|
19713
|
+
if (typeof outcome === "symbol") {
|
|
19714
|
+
const line = alreadyLiveLine(session2.kind.kind, name2, revision);
|
|
19715
|
+
if (session2.values.json)
|
|
19716
|
+
writeOutput(
|
|
19717
|
+
session2.options,
|
|
19718
|
+
JSON.stringify({ status: "already_live", liveRevision: revision }, null, 2)
|
|
19719
|
+
);
|
|
19720
|
+
else writeOutput(session2.options, line);
|
|
19721
|
+
return EXIT3.done;
|
|
19722
|
+
}
|
|
19323
19723
|
return settle(
|
|
19324
19724
|
session2,
|
|
19325
19725
|
outcome,
|
|
@@ -19331,7 +19731,8 @@ var publishVerb = {
|
|
|
19331
19731
|
// An agent's first version without a draft replaces nothing: it is offered as made.
|
|
19332
19732
|
output.replacedRevision !== void 0 && (agent || session2.kind.kind === "skill") ? `Published draft revision ${output.draftRevision} of ${session2.kind.kind} '${name2}' as live revision ${output.publishedRevision}${output.replacedRevision === void 0 ? "" : ` in place of revision ${output.replacedRevision}`}.` : `Published revision ${output.publishedRevision} of ${session2.kind.kind} '${name2}'${output.replacedRevision === void 0 ? "" : ` in place of revision ${output.replacedRevision}`}.`
|
|
19333
19733
|
],
|
|
19334
|
-
asks ? "If you are an instance approver, you can approve it in the Inbox." : void 0
|
|
19734
|
+
asks ? "If you are an instance approver, you can approve it in the Inbox." : void 0,
|
|
19735
|
+
OVERTAKEN_LINE
|
|
19335
19736
|
);
|
|
19336
19737
|
};
|
|
19337
19738
|
}
|
|
@@ -19616,24 +20017,37 @@ async function setDefault(api, kind, name2, scope, defaultOf) {
|
|
|
19616
20017
|
}
|
|
19617
20018
|
|
|
19618
20019
|
// src/asset-verbs/set-availability.ts
|
|
20020
|
+
function isAvailabilityMode(mode) {
|
|
20021
|
+
return AGENT_AVAILABILITY_MODES.some((known) => known === mode);
|
|
20022
|
+
}
|
|
19619
20023
|
var setAvailabilityVerb = {
|
|
19620
|
-
usage: "set-availability <name> --mode all|selected [--personal] [--available-in <workspace-id>]...",
|
|
20024
|
+
usage: "set-availability <name> --mode all|selected|all_except [--personal] [--available-in <workspace-id>]... [--except <workspace-id>]...",
|
|
19621
20025
|
summary: "Set the workspaces one asset is offered in (assets.set_availability)",
|
|
19622
20026
|
named: true,
|
|
19623
20027
|
options: {
|
|
19624
20028
|
mode: { type: "string" },
|
|
19625
20029
|
personal: { type: "boolean", default: false },
|
|
19626
|
-
"available-in": { type: "string", multiple: true }
|
|
20030
|
+
"available-in": { type: "string", multiple: true },
|
|
20031
|
+
except: { type: "string", multiple: true }
|
|
19627
20032
|
},
|
|
19628
20033
|
prepare: (values, name2) => {
|
|
19629
|
-
const
|
|
19630
|
-
if (mode
|
|
19631
|
-
throw new UsageError("--mode is 'all' or '
|
|
20034
|
+
const mode = values.mode;
|
|
20035
|
+
if (!isAvailabilityMode(mode)) {
|
|
20036
|
+
throw new UsageError("--mode is 'all', 'selected' or 'all_except'.");
|
|
20037
|
+
}
|
|
20038
|
+
if (mode !== "selected" && values["available-in"]?.length) {
|
|
20039
|
+
throw new UsageError("--available-in goes with --mode selected.");
|
|
20040
|
+
}
|
|
20041
|
+
if (mode !== "all_except" && values.except?.length) {
|
|
20042
|
+
throw new UsageError("--except goes with --mode all_except.");
|
|
20043
|
+
}
|
|
20044
|
+
if (mode === "all" && values.personal) {
|
|
20045
|
+
throw new UsageError("--personal goes with --mode selected or all_except.");
|
|
19632
20046
|
}
|
|
19633
20047
|
const body = {
|
|
19634
|
-
mode
|
|
20048
|
+
mode,
|
|
19635
20049
|
personalWorkspaces: values.personal,
|
|
19636
|
-
collaborationWorkspaceIds: values["available-in"] ?? []
|
|
20050
|
+
collaborationWorkspaceIds: (mode === "all_except" ? values.except : values["available-in"]) ?? []
|
|
19637
20051
|
};
|
|
19638
20052
|
return async (session2) => {
|
|
19639
20053
|
const outcome = await setAvailability(
|
|
@@ -19644,7 +20058,7 @@ var setAvailabilityVerb = {
|
|
|
19644
20058
|
session2.scope
|
|
19645
20059
|
);
|
|
19646
20060
|
return settle(session2, outcome, (output) => [
|
|
19647
|
-
`${session2.kind.kind} '${name2}' is offered in ${output
|
|
20061
|
+
`${session2.kind.kind} '${name2}' is offered in ${availabilityPhrase(output)}.`
|
|
19648
20062
|
]);
|
|
19649
20063
|
};
|
|
19650
20064
|
}
|
|
@@ -20135,6 +20549,23 @@ async function setupCommand(options) {
|
|
|
20135
20549
|
return 1;
|
|
20136
20550
|
}
|
|
20137
20551
|
}
|
|
20552
|
+
async function refreshWrittenSkills(env) {
|
|
20553
|
+
const skill = await renderCatalystSkill();
|
|
20554
|
+
const paths = [
|
|
20555
|
+
...new Set(
|
|
20556
|
+
Object.keys(LOCAL_AGENT_TOOLS).filter(isLocalAgentTool).map((tool) => catalystSkillPath(tool, env))
|
|
20557
|
+
)
|
|
20558
|
+
];
|
|
20559
|
+
const refreshed = [];
|
|
20560
|
+
for (const path of paths) {
|
|
20561
|
+
const existing = await readSkillFile(path).catch(() => void 0);
|
|
20562
|
+
if (typeof existing === "string" && existing !== skill && writtenBySetup(existing)) {
|
|
20563
|
+
await replaceFile(path, skill);
|
|
20564
|
+
refreshed.push(path);
|
|
20565
|
+
}
|
|
20566
|
+
}
|
|
20567
|
+
return refreshed;
|
|
20568
|
+
}
|
|
20138
20569
|
var NOT_A_FILE = /* @__PURE__ */ Symbol("not a file");
|
|
20139
20570
|
async function readSkillFile(path) {
|
|
20140
20571
|
const entry = await lstat4(path).catch((error) => {
|
|
@@ -21013,7 +21444,7 @@ import yaml7 from "js-yaml";
|
|
|
21013
21444
|
import { readFile as readFile10 } from "fs/promises";
|
|
21014
21445
|
import { basename as basename5, resolve as resolve11 } from "path";
|
|
21015
21446
|
import { parseArgs as parseArgs5 } from "util";
|
|
21016
|
-
import { z as
|
|
21447
|
+
import { z as z71 } from "zod";
|
|
21017
21448
|
|
|
21018
21449
|
// src/connection-sign-in.ts
|
|
21019
21450
|
import { setTimeout as defaultSleep3 } from "timers/promises";
|
|
@@ -21142,11 +21573,11 @@ async function readSecret(input, prompt) {
|
|
|
21142
21573
|
}
|
|
21143
21574
|
|
|
21144
21575
|
// src/operation-commands.ts
|
|
21145
|
-
var requestSchema =
|
|
21146
|
-
params:
|
|
21147
|
-
query:
|
|
21148
|
-
body:
|
|
21149
|
-
file:
|
|
21576
|
+
var requestSchema = z71.strictObject({
|
|
21577
|
+
params: z71.record(z71.string(), z71.string()).optional(),
|
|
21578
|
+
query: z71.record(z71.string(), z71.union([z71.string(), z71.number(), z71.boolean()])).optional(),
|
|
21579
|
+
body: z71.unknown().optional(),
|
|
21580
|
+
file: z71.string().optional()
|
|
21150
21581
|
});
|
|
21151
21582
|
var UsageError2 = class extends Error {
|
|
21152
21583
|
};
|
|
@@ -21255,7 +21686,7 @@ async function runOperationCommand(argv, base) {
|
|
|
21255
21686
|
secret = value;
|
|
21256
21687
|
if (value.length === 0) throw new UsageError2("The secret must not be empty.");
|
|
21257
21688
|
if (values.test) {
|
|
21258
|
-
const
|
|
21689
|
+
const state3 = await api2.change(
|
|
21259
21690
|
(client, idempotencyKey2) => client.connections.set_test_credential({
|
|
21260
21691
|
params: { name: connectionName },
|
|
21261
21692
|
body: {
|
|
@@ -21276,10 +21707,10 @@ async function runOperationCommand(argv, base) {
|
|
|
21276
21707
|
);
|
|
21277
21708
|
return testCredential;
|
|
21278
21709
|
});
|
|
21279
|
-
writeOutput(options, JSON.stringify(
|
|
21710
|
+
writeOutput(options, JSON.stringify(state3, null, 2));
|
|
21280
21711
|
return 0;
|
|
21281
21712
|
}
|
|
21282
|
-
const
|
|
21713
|
+
const state2 = await api2.change(
|
|
21283
21714
|
(client, idempotencyKey2) => client.connections.set_secret({
|
|
21284
21715
|
params: { name: connectionName },
|
|
21285
21716
|
body: {
|
|
@@ -21295,7 +21726,7 @@ async function runOperationCommand(argv, base) {
|
|
|
21295
21726
|
throw error;
|
|
21296
21727
|
return (await api2.read((client) => client.connections.get({ params: { name: connectionName } }))).secret;
|
|
21297
21728
|
});
|
|
21298
|
-
writeOutput(options, JSON.stringify(
|
|
21729
|
+
writeOutput(options, JSON.stringify(state2, null, 2));
|
|
21299
21730
|
return 0;
|
|
21300
21731
|
}
|
|
21301
21732
|
if (verb === "connect") {
|
|
@@ -21869,7 +22300,7 @@ var initGroup = {
|
|
|
21869
22300
|
// src/knowledge-commands.ts
|
|
21870
22301
|
import { parseArgs as parseArgs10 } from "util";
|
|
21871
22302
|
import yaml11 from "js-yaml";
|
|
21872
|
-
import { z as
|
|
22303
|
+
import { z as z72 } from "zod";
|
|
21873
22304
|
var knowledgeHelpText = `Knowledge Base sources (draft changes take effect at publish):
|
|
21874
22305
|
knowledge-base source add <kb> --source <id> --connection <name> --folder <id>... [--include <glob>...] [--exclude <glob>...]
|
|
21875
22306
|
knowledge-base source list <kb>
|
|
@@ -21934,8 +22365,8 @@ async function runKnowledgeCommand(argv, base) {
|
|
|
21934
22365
|
if (command === "add" || command === "remove" || command === "list") {
|
|
21935
22366
|
const asset = await api.getAsset("knowledge_base", name2);
|
|
21936
22367
|
if (!asset) throw new Error("The Knowledge Base is not available.");
|
|
21937
|
-
const config =
|
|
21938
|
-
const sources =
|
|
22368
|
+
const config = z72.record(z72.string(), z72.unknown()).parse(asset.config);
|
|
22369
|
+
const sources = z72.array(z72.record(z72.string(), z72.unknown())).parse(config.sources ?? []);
|
|
21939
22370
|
if (command === "list") result = sources;
|
|
21940
22371
|
else {
|
|
21941
22372
|
const remaining = sources.filter((s) => s.id !== values.source);
|
|
@@ -21973,7 +22404,7 @@ async function runKnowledgeCommand(argv, base) {
|
|
|
21973
22404
|
const output = await call2(api, apiOperations["knowledge_bases.sources"], {
|
|
21974
22405
|
params: { knowledgeBase: name2 }
|
|
21975
22406
|
});
|
|
21976
|
-
const parsed2 =
|
|
22407
|
+
const parsed2 = z72.object({ sources: z72.array(z72.object({ id: z72.string() }).passthrough()) }).parse(output);
|
|
21977
22408
|
result = {
|
|
21978
22409
|
sources: values.source ? parsed2.sources.filter((s) => s.id === values.source) : parsed2.sources
|
|
21979
22410
|
};
|
|
@@ -22003,14 +22434,14 @@ async function runKnowledgeCommand(argv, base) {
|
|
|
22003
22434
|
return 1;
|
|
22004
22435
|
}
|
|
22005
22436
|
}
|
|
22006
|
-
var reindexAnswerSchema =
|
|
22007
|
-
started:
|
|
22008
|
-
state:
|
|
22009
|
-
active:
|
|
22010
|
-
target:
|
|
22011
|
-
progress:
|
|
22012
|
-
statement:
|
|
22013
|
-
lines:
|
|
22437
|
+
var reindexAnswerSchema = z72.object({
|
|
22438
|
+
started: z72.boolean(),
|
|
22439
|
+
state: z72.string(),
|
|
22440
|
+
active: z72.object({ model: z72.string() }).passthrough().optional(),
|
|
22441
|
+
target: z72.object({ model: z72.string() }).passthrough().optional(),
|
|
22442
|
+
progress: z72.object({ embedded: z72.number(), total: z72.number() }).optional(),
|
|
22443
|
+
statement: z72.object({ confirmation: z72.string(), room: z72.boolean() }).passthrough().optional(),
|
|
22444
|
+
lines: z72.array(z72.string()).optional()
|
|
22014
22445
|
}).passthrough();
|
|
22015
22446
|
async function reindex(api, name2, confirm, options, json2) {
|
|
22016
22447
|
const raw = await call2(api, apiOperations["knowledge_bases.reindex"], {
|
|
@@ -23006,10 +23437,10 @@ async function listProviders(configFlag, json2, options) {
|
|
|
23006
23437
|
}
|
|
23007
23438
|
writeOutput(options, `Model providers of ${shownPath(options.cwd, path)}:`);
|
|
23008
23439
|
for (const provider of listed) {
|
|
23009
|
-
const
|
|
23440
|
+
const state2 = provider.instance === void 0 ? "" : provider.instance === "absent" ? " instance: not deployed" : ` instance: ${provider.instance.check.status === "failed" ? `failed (${provider.instance.check.errorClass})` : provider.instance.check.status.replace("_", " ")}${provider.instance.secrets.some((secret) => secret.state === "missing") ? ", secret missing" : ""}`;
|
|
23010
23441
|
writeOutput(
|
|
23011
23442
|
options,
|
|
23012
|
-
` ${provider.id} ${provider.provider}, region ${provider.region ?? "unset"}${provider.secret ? `, secret ${provider.secret}` : ""}, bindings: ${provider.bindings.length > 0 ? provider.bindings.join(", ") : "none"}${provider.priced ? "" : ", not priced"}${
|
|
23443
|
+
` ${provider.id} ${provider.provider}, region ${provider.region ?? "unset"}${provider.secret ? `, secret ${provider.secret}` : ""}, bindings: ${provider.bindings.length > 0 ? provider.bindings.join(", ") : "none"}${provider.priced ? "" : ", not priced"}${state2}`
|
|
23013
23444
|
);
|
|
23014
23445
|
}
|
|
23015
23446
|
return 0;
|
|
@@ -23588,12 +24019,22 @@ async function runCli(argv, runtime = {}) {
|
|
|
23588
24019
|
return group.run(argv, { ...runtime, cwd: runtime.cwd ?? process.cwd(), stdout, stderr });
|
|
23589
24020
|
}
|
|
23590
24021
|
var entryPath = process.argv[1];
|
|
23591
|
-
if (entryPath && import.meta.url === pathToFileURL(
|
|
24022
|
+
if (entryPath && import.meta.url === pathToFileURL(realpathSync2(entryPath)).href) {
|
|
24023
|
+
const env = readConfigCliEnv();
|
|
24024
|
+
if (env.CATALYST_CLI_UPDATED_FROM !== void 0) {
|
|
24025
|
+
const refreshed = await refreshWrittenSkills(env).catch(() => []);
|
|
24026
|
+
if (refreshed.length > 0) {
|
|
24027
|
+
process.stderr.write(`Updated the Catalyst skill at ${refreshed.join(" and ")}.
|
|
24028
|
+
`);
|
|
24029
|
+
}
|
|
24030
|
+
}
|
|
24031
|
+
enableSelfUpdate(process.argv.slice(2));
|
|
23592
24032
|
process.exitCode = await runCli(process.argv.slice(2));
|
|
23593
24033
|
}
|
|
23594
24034
|
export {
|
|
23595
24035
|
ApiKeyExchangeError,
|
|
23596
24036
|
CANONICAL_FORM_VERSION,
|
|
24037
|
+
CliVersionError,
|
|
23597
24038
|
ConfigApiError,
|
|
23598
24039
|
MANIFEST_FILENAME,
|
|
23599
24040
|
STATE_FILENAME,
|
|
@@ -23610,11 +24051,13 @@ export {
|
|
|
23610
24051
|
createSkillFileDiff,
|
|
23611
24052
|
createUnifiedDiff,
|
|
23612
24053
|
diffConfig,
|
|
24054
|
+
enableSelfUpdate,
|
|
23613
24055
|
guardrailAssetPath,
|
|
23614
24056
|
instanceFetch,
|
|
23615
24057
|
listConfig,
|
|
23616
24058
|
matchManifestFiles,
|
|
23617
24059
|
matchesManifestPath,
|
|
24060
|
+
npmCommand,
|
|
23618
24061
|
parseAgentYaml,
|
|
23619
24062
|
parseManifest,
|
|
23620
24063
|
parseSkillFile,
|
|
@@ -23627,6 +24070,8 @@ export {
|
|
|
23627
24070
|
readStateFile,
|
|
23628
24071
|
readWorkingCopy,
|
|
23629
24072
|
redactSecret,
|
|
24073
|
+
refreshWrittenSkills,
|
|
24074
|
+
releaseVersionOf,
|
|
23630
24075
|
removeStaleManifestAssets,
|
|
23631
24076
|
renderCatalystSkill,
|
|
23632
24077
|
resolveInstance,
|
|
@@ -23640,6 +24085,7 @@ export {
|
|
|
23640
24085
|
skillAssetPath,
|
|
23641
24086
|
toConfigApiError,
|
|
23642
24087
|
updateManifestDefaultAgent,
|
|
24088
|
+
updateToServerVersion,
|
|
23643
24089
|
validateConfig,
|
|
23644
24090
|
walkFiles,
|
|
23645
24091
|
writeStateFile
|