@work-shape/catalyst-cli 0.8.0-rc.31 → 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 +349 -15
- package/dist/index.js +572 -127
- 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),
|
|
@@ -5665,7 +5733,11 @@ var knowledgeCitationSourceSchema = z33.object({
|
|
|
5665
5733
|
fileName: z33.string().min(1),
|
|
5666
5734
|
page: z33.number().int().positive().optional(),
|
|
5667
5735
|
sheet: z33.string().min(1).optional(),
|
|
5668
|
-
originLink: z33.string().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()
|
|
5669
5741
|
});
|
|
5670
5742
|
var messageCitationSchema = z33.object({
|
|
5671
5743
|
sourceId: z33.string(),
|
|
@@ -6450,7 +6522,22 @@ var conversationThreadSnapshotSchema = z33.object({
|
|
|
6450
6522
|
* The agent of each run the conversation held, oldest first, by the message that started the
|
|
6451
6523
|
* run: where another agent answers from that message on, the history says so (T30).
|
|
6452
6524
|
*/
|
|
6453
|
-
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(),
|
|
6454
6541
|
/**
|
|
6455
6542
|
* What the conversation's latest run was asked to use. Absent before the first run; a run that
|
|
6456
6543
|
* followed the configured defaults leaves both fields out.
|
|
@@ -7461,6 +7548,11 @@ var approvalRequestSchema = z38.object({
|
|
|
7461
7548
|
* Absent on a request the holders of a right decide.
|
|
7462
7549
|
*/
|
|
7463
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(),
|
|
7464
7556
|
status: approvalRequestStatusSchema,
|
|
7465
7557
|
decision: z38.object({
|
|
7466
7558
|
approved: z38.boolean(),
|
|
@@ -7482,10 +7574,15 @@ var approvalRequestViewSchema = approvalRequestSchema.extend({
|
|
|
7482
7574
|
canWithdraw: z38.boolean(),
|
|
7483
7575
|
canRevert: z38.boolean()
|
|
7484
7576
|
});
|
|
7577
|
+
var APPROVAL_REQUEST_LIST_SCOPES = ["decided", "others_own"];
|
|
7485
7578
|
var listApprovalRequestsQuerySchema = z38.object({
|
|
7486
7579
|
status: approvalRequestStatusSchema.optional(),
|
|
7487
|
-
/**
|
|
7488
|
-
|
|
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()
|
|
7489
7586
|
});
|
|
7490
7587
|
var pendingApprovalRequestCountSchema = z38.object({
|
|
7491
7588
|
/** The pending requests the caller can decide. */
|
|
@@ -7493,6 +7590,11 @@ var pendingApprovalRequestCountSchema = z38.object({
|
|
|
7493
7590
|
canReview: z38.boolean(),
|
|
7494
7591
|
/** How many requests the list with `scope=decided` holds for the caller. */
|
|
7495
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(),
|
|
7496
7598
|
/** The requests the caller made: those still pending, and all of them. */
|
|
7497
7599
|
mine: z38.object({
|
|
7498
7600
|
pending: z38.number().int().nonnegative(),
|
|
@@ -9034,9 +9136,27 @@ var connectorTypeOffersSchema = z44.object({
|
|
|
9034
9136
|
help: localizedTextSchema.optional(),
|
|
9035
9137
|
optional: z44.boolean(),
|
|
9036
9138
|
setting: z44.string().optional(),
|
|
9037
|
-
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()
|
|
9038
9146
|
})
|
|
9039
|
-
)
|
|
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))
|
|
9040
9160
|
})
|
|
9041
9161
|
),
|
|
9042
9162
|
/**
|
|
@@ -10286,6 +10406,53 @@ var conversationOperations = {
|
|
|
10286
10406
|
errors: ["NOT_FOUND", "CONFLICT"],
|
|
10287
10407
|
rateClass: "write"
|
|
10288
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
|
+
}),
|
|
10289
10456
|
"conversations.thread.get": defineOperation({
|
|
10290
10457
|
id: "conversations.thread.get",
|
|
10291
10458
|
method: "GET",
|
|
@@ -11763,7 +11930,14 @@ var knowledgeSearchResponseSchema = z57.object({
|
|
|
11763
11930
|
text: z57.string(),
|
|
11764
11931
|
/** Reciprocal rank fusion of the lists in `signals`: compare it only within one Knowledge Base. */
|
|
11765
11932
|
score: z57.number(),
|
|
11766
|
-
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()
|
|
11767
11941
|
})
|
|
11768
11942
|
),
|
|
11769
11943
|
/** The ranked lists fused: `semantic`, `keyword` and `title`. */
|
|
@@ -14641,10 +14815,14 @@ function cliCompatibilityError(cliVersion, serverVersion) {
|
|
|
14641
14815
|
}
|
|
14642
14816
|
return cliVersion.split("+")[0] === serverVersion.split("+")[0] ? void 0 : new CliVersionError(cliVersion, serverVersion);
|
|
14643
14817
|
}
|
|
14818
|
+
function releaseVersionOf(serverVersion) {
|
|
14819
|
+
const release = serverVersion.split("+")[0] ?? "";
|
|
14820
|
+
return release.length <= 64 && versionParts(release) ? release : void 0;
|
|
14821
|
+
}
|
|
14644
14822
|
var CliVersionError = class extends Error {
|
|
14645
|
-
constructor(cliVersion, serverVersion) {
|
|
14823
|
+
constructor(cliVersion, serverVersion, instead) {
|
|
14646
14824
|
super(
|
|
14647
|
-
`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]}`}`
|
|
14648
14826
|
);
|
|
14649
14827
|
this.cliVersion = cliVersion;
|
|
14650
14828
|
this.serverVersion = serverVersion;
|
|
@@ -14654,6 +14832,195 @@ var CliVersionError = class extends Error {
|
|
|
14654
14832
|
serverVersion;
|
|
14655
14833
|
};
|
|
14656
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
|
+
|
|
14657
15024
|
// src/api.ts
|
|
14658
15025
|
var ConfigApiError = class extends Error {
|
|
14659
15026
|
status;
|
|
@@ -14848,9 +15215,10 @@ function instanceFetch(fetchImpl, diagnostics = {}) {
|
|
|
14848
15215
|
const mismatch = cliCompatibilityError(RELEASE_VERSION, serverVersion);
|
|
14849
15216
|
if (diagnostics.checkVersion !== false && mismatch) {
|
|
14850
15217
|
await response.body?.cancel();
|
|
14851
|
-
throw mismatch;
|
|
15218
|
+
throw mismatch instanceof CliVersionError ? await onCliVersionMismatch(mismatch) : mismatch;
|
|
14852
15219
|
}
|
|
14853
15220
|
}
|
|
15221
|
+
onInstanceAnswer();
|
|
14854
15222
|
return response;
|
|
14855
15223
|
};
|
|
14856
15224
|
}
|
|
@@ -14964,9 +15332,9 @@ async function readFolderState(directory, filename, kind) {
|
|
|
14964
15332
|
name: name2
|
|
14965
15333
|
};
|
|
14966
15334
|
}
|
|
14967
|
-
async function writeFolderState(directory, filename,
|
|
15335
|
+
async function writeFolderState(directory, filename, state2) {
|
|
14968
15336
|
const path = join(directory, filename);
|
|
14969
|
-
await writeFile(`${path}.tmp`, `${JSON.stringify(
|
|
15337
|
+
await writeFile(`${path}.tmp`, `${JSON.stringify(state2, null, 2)}
|
|
14970
15338
|
`, { mode: 420 });
|
|
14971
15339
|
await rename(`${path}.tmp`, path);
|
|
14972
15340
|
}
|
|
@@ -14984,13 +15352,13 @@ async function refuseLinks(directory, recursive = true) {
|
|
|
14984
15352
|
for (const entry of await readdir(directory)) await refuseLinks(join(directory, entry));
|
|
14985
15353
|
}
|
|
14986
15354
|
}
|
|
14987
|
-
async function localChanges(directory,
|
|
15355
|
+
async function localChanges(directory, state2, filename, ignoreUntracked = false) {
|
|
14988
15356
|
const now = {};
|
|
14989
15357
|
const walk2 = async (folder, prefix) => {
|
|
14990
15358
|
for (const entry of await readdir(folder, { withFileTypes: true })) {
|
|
14991
15359
|
const path = `${prefix}${entry.name}`;
|
|
14992
15360
|
if (path === filename || entry.name === ".DS_Store" && entry.isFile()) continue;
|
|
14993
|
-
const tracked = Object.hasOwn(
|
|
15361
|
+
const tracked = Object.hasOwn(state2.files, path) || Object.keys(state2.files).some((file) => file.startsWith(`${path}/`));
|
|
14994
15362
|
if (ignoreUntracked && !tracked && (entry.name.startsWith(".") || entry.isDirectory() && entry.name === "node_modules"))
|
|
14995
15363
|
continue;
|
|
14996
15364
|
if (entry.isDirectory()) await walk2(join(folder, entry.name), `${path}/`);
|
|
@@ -15004,10 +15372,10 @@ async function localChanges(directory, state, filename, ignoreUntracked = false)
|
|
|
15004
15372
|
await walk2(directory, "");
|
|
15005
15373
|
return {
|
|
15006
15374
|
changed: Object.keys(now).filter(
|
|
15007
|
-
(path) => Object.hasOwn(
|
|
15375
|
+
(path) => Object.hasOwn(state2.files, path) && now[path] !== state2.files[path]
|
|
15008
15376
|
),
|
|
15009
|
-
added: Object.keys(now).filter((path) => !Object.hasOwn(
|
|
15010
|
-
removed: Object.keys(
|
|
15377
|
+
added: Object.keys(now).filter((path) => !Object.hasOwn(state2.files, path)),
|
|
15378
|
+
removed: Object.keys(state2.files).filter(
|
|
15011
15379
|
(path) => basename(path) !== ".DS_Store" && !Object.hasOwn(now, path)
|
|
15012
15380
|
)
|
|
15013
15381
|
};
|
|
@@ -15032,7 +15400,7 @@ async function writeFolderFiles(directory, files, previous) {
|
|
|
15032
15400
|
}
|
|
15033
15401
|
return hashes;
|
|
15034
15402
|
}
|
|
15035
|
-
async function replaceFolder(directory, files, filename,
|
|
15403
|
+
async function replaceFolder(directory, files, filename, state2, beforeReplace) {
|
|
15036
15404
|
const createdParent = await mkdir(dirname(directory), { recursive: true });
|
|
15037
15405
|
let temporary;
|
|
15038
15406
|
let installed = false;
|
|
@@ -15045,7 +15413,7 @@ async function replaceFolder(directory, files, filename, state, beforeReplace) {
|
|
|
15045
15413
|
if (files.some((file) => file.path === filename))
|
|
15046
15414
|
throw new Error(`The instance named the reserved state file '${filename}'.`);
|
|
15047
15415
|
const hashes = await writeFolderFiles(staged, files);
|
|
15048
|
-
await writeFolderState(staged, filename, { ...
|
|
15416
|
+
await writeFolderState(staged, filename, { ...state2, files: hashes });
|
|
15049
15417
|
await beforeReplace();
|
|
15050
15418
|
try {
|
|
15051
15419
|
await rename(directory, backup);
|
|
@@ -15271,11 +15639,6 @@ function isCredentialFile(value) {
|
|
|
15271
15639
|
);
|
|
15272
15640
|
}
|
|
15273
15641
|
|
|
15274
|
-
// src/env.ts
|
|
15275
|
-
function readConfigCliEnv(env) {
|
|
15276
|
-
return env ?? process.env;
|
|
15277
|
-
}
|
|
15278
|
-
|
|
15279
15642
|
// src/guardrail-files.ts
|
|
15280
15643
|
import { readFile as readFile4, stat as stat2 } from "fs/promises";
|
|
15281
15644
|
import { join as join4 } from "path";
|
|
@@ -15592,10 +15955,10 @@ function readBaselineHashes(input) {
|
|
|
15592
15955
|
})
|
|
15593
15956
|
);
|
|
15594
15957
|
}
|
|
15595
|
-
async function writeStateFile(path,
|
|
15958
|
+
async function writeStateFile(path, state2) {
|
|
15596
15959
|
await mkdir3(dirname3(path), { recursive: true });
|
|
15597
15960
|
const temporaryPath = `${path}.${process.pid}.tmp`;
|
|
15598
|
-
await writeFile3(temporaryPath, `${JSON.stringify(
|
|
15961
|
+
await writeFile3(temporaryPath, `${JSON.stringify(state2, null, 2)}
|
|
15599
15962
|
`, "utf8");
|
|
15600
15963
|
await rename3(temporaryPath, path);
|
|
15601
15964
|
}
|
|
@@ -16283,8 +16646,8 @@ async function openInstance(options) {
|
|
|
16283
16646
|
}
|
|
16284
16647
|
async function recordBaseline(workingDir, instanceKey, version, bundle, revisions, fullPull, defaultAgentName, tombstones = {}) {
|
|
16285
16648
|
const path = resolve4(workingDir, STATE_FILENAME);
|
|
16286
|
-
const
|
|
16287
|
-
const previous =
|
|
16649
|
+
const state2 = await readStateFile(path);
|
|
16650
|
+
const previous = state2.instances[instanceKey];
|
|
16288
16651
|
const baseline = {
|
|
16289
16652
|
...previous,
|
|
16290
16653
|
lastPulledVersion: fullPull ? version : previous?.lastPulledVersion ?? version
|
|
@@ -16321,7 +16684,7 @@ async function recordBaseline(workingDir, instanceKey, version, bundle, revision
|
|
|
16321
16684
|
if (defaultAgentName !== void 0) {
|
|
16322
16685
|
baseline.defaultAgentName = defaultAgentName;
|
|
16323
16686
|
}
|
|
16324
|
-
await writeStateFile(path, { instances: { ...
|
|
16687
|
+
await writeStateFile(path, { instances: { ...state2.instances, [instanceKey]: baseline } });
|
|
16325
16688
|
}
|
|
16326
16689
|
function resolveWorkingDir(options) {
|
|
16327
16690
|
return resolve4(options.cwd, options.dir ?? ".");
|
|
@@ -16738,18 +17101,18 @@ var REPOSITORY_KINDS = {
|
|
|
16738
17101
|
}
|
|
16739
17102
|
};
|
|
16740
17103
|
async function readRepositoryState(directory, kind) {
|
|
16741
|
-
const
|
|
16742
|
-
if (
|
|
16743
|
-
return
|
|
17104
|
+
const state2 = await readFolderState(directory, APP_STATE_FILE, kind.kind);
|
|
17105
|
+
if (state2 === void 0) return void 0;
|
|
17106
|
+
return state2;
|
|
16744
17107
|
}
|
|
16745
|
-
async function writeRepositoryState(directory,
|
|
17108
|
+
async function writeRepositoryState(directory, state2, kind) {
|
|
16746
17109
|
await writeFolderState(directory, APP_STATE_FILE, {
|
|
16747
|
-
instance:
|
|
16748
|
-
workspaceId:
|
|
16749
|
-
[kind.kind]:
|
|
16750
|
-
assetId:
|
|
16751
|
-
revision:
|
|
16752
|
-
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
|
|
16753
17116
|
});
|
|
16754
17117
|
}
|
|
16755
17118
|
async function readRepositoryFolder(directory, limits, tracked, kind) {
|
|
@@ -16823,8 +17186,8 @@ async function walk(root, directory, tracked, found, leftOut) {
|
|
|
16823
17186
|
}
|
|
16824
17187
|
}
|
|
16825
17188
|
}
|
|
16826
|
-
async function localChanges2(directory,
|
|
16827
|
-
return localChanges(directory,
|
|
17189
|
+
async function localChanges2(directory, state2) {
|
|
17190
|
+
return localChanges(directory, state2, APP_STATE_FILE, true);
|
|
16828
17191
|
}
|
|
16829
17192
|
function utf8Text2(bytes) {
|
|
16830
17193
|
try {
|
|
@@ -16904,6 +17267,19 @@ function formatAssetList(kind, assets) {
|
|
|
16904
17267
|
])
|
|
16905
17268
|
);
|
|
16906
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
|
+
}
|
|
16907
17283
|
function formatAsset(asset) {
|
|
16908
17284
|
const facts = [
|
|
16909
17285
|
["kind", asset.kind],
|
|
@@ -16915,13 +17291,7 @@ function formatAsset(asset) {
|
|
|
16915
17291
|
["content of revision", asset.contentRevision?.toString()],
|
|
16916
17292
|
["scope", scopeLabel(asset.scope)],
|
|
16917
17293
|
["default", asset.isDefault ? "yes" : void 0],
|
|
16918
|
-
[
|
|
16919
|
-
"available in",
|
|
16920
|
-
asset.availability && (asset.availability.mode === "all" ? "every workspace" : list([
|
|
16921
|
-
...asset.availability.personalWorkspaces ? ["personal workspaces"] : [],
|
|
16922
|
-
...asset.availability.collaborationWorkspaceIds
|
|
16923
|
-
]))
|
|
16924
|
-
],
|
|
17294
|
+
["available in", asset.availability && availabilityPhrase(asset.availability)],
|
|
16925
17295
|
["updated", asset.updatedAt]
|
|
16926
17296
|
];
|
|
16927
17297
|
const lines = facts.flatMap(
|
|
@@ -17040,12 +17410,19 @@ async function askBeforePublish(options, publish2) {
|
|
|
17040
17410
|
writeError(options, "Nothing was published.");
|
|
17041
17411
|
return "refused";
|
|
17042
17412
|
}
|
|
17043
|
-
|
|
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) {
|
|
17044
17421
|
const named = `${run.approvalRequestId === void 0 ? "" : `request ${run.approvalRequestId}, `}Operation Run ${run.id}`;
|
|
17045
17422
|
if (run.status === "pending_confirmation") {
|
|
17046
|
-
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}` : ""}`;
|
|
17047
17424
|
}
|
|
17048
|
-
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}` : ""}`;
|
|
17049
17426
|
}
|
|
17050
17427
|
function agentPublishRefusalHint(error) {
|
|
17051
17428
|
if (!(error instanceof ConfigApiError) || error.status !== 403) return void 0;
|
|
@@ -17194,8 +17571,8 @@ async function pull(app, directory, values, options, kind) {
|
|
|
17194
17571
|
return EXIT.done;
|
|
17195
17572
|
}
|
|
17196
17573
|
async function push(directory, values, options, kind) {
|
|
17197
|
-
const
|
|
17198
|
-
const target = await openRepository(options, values,
|
|
17574
|
+
const state2 = await readRepositoryState(directory, kind);
|
|
17575
|
+
const target = await openRepository(options, values, state2, kind);
|
|
17199
17576
|
const registered = target.kinds.find((candidate) => candidate.kind === kind.kind);
|
|
17200
17577
|
if (registered === void 0) {
|
|
17201
17578
|
throw new Error(
|
|
@@ -17205,44 +17582,44 @@ async function push(directory, values, options, kind) {
|
|
|
17205
17582
|
const read2 = await readRepositoryFolder(
|
|
17206
17583
|
directory,
|
|
17207
17584
|
registered.limits,
|
|
17208
|
-
new Set(Object.keys(
|
|
17585
|
+
new Set(Object.keys(state2?.files ?? {})),
|
|
17209
17586
|
kind
|
|
17210
17587
|
);
|
|
17211
|
-
const name2 =
|
|
17212
|
-
if (
|
|
17588
|
+
const name2 = state2?.name ?? repositoryIdOf(read2.files, kind);
|
|
17589
|
+
if (state2 === void 0 && name2 === void 0) {
|
|
17213
17590
|
throw new RepositoryUsageError(
|
|
17214
17591
|
`${kind.manifest} names no \`id\`. The id is the ${kind.label}'s name on the instance: add \`id: <name>\` to ${kind.manifest}.`
|
|
17215
17592
|
);
|
|
17216
17593
|
}
|
|
17217
17594
|
const app = name2 ?? "";
|
|
17218
|
-
const declared =
|
|
17219
|
-
if (
|
|
17595
|
+
const declared = state2 === void 0 ? void 0 : declaredIdOf(read2.files, kind);
|
|
17596
|
+
if (state2 !== void 0 && declared !== void 0 && declared !== state2.name) {
|
|
17220
17597
|
throw new RepositoryUsageError(
|
|
17221
|
-
`${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}'.`
|
|
17222
17599
|
);
|
|
17223
17600
|
}
|
|
17224
|
-
const expectedRevision =
|
|
17225
|
-
if (
|
|
17601
|
+
const expectedRevision = state2?.revision ?? null;
|
|
17602
|
+
if (state2 !== void 0 && state2.workspaceId !== target.workspaceId) {
|
|
17226
17603
|
throw new RepositoryUsageError(
|
|
17227
|
-
`'${directory}' was pulled from workspace ${
|
|
17604
|
+
`'${directory}' was pulled from workspace ${state2.workspaceId}, and the command names ${target.workspaceId}.`
|
|
17228
17605
|
);
|
|
17229
17606
|
}
|
|
17230
|
-
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)) {
|
|
17231
17608
|
const current = await target.api.read(
|
|
17232
17609
|
(client) => client.assets.get({
|
|
17233
17610
|
params: { kind: kind.kind, name: app },
|
|
17234
17611
|
query: { workspaceId: target.workspaceId }
|
|
17235
17612
|
})
|
|
17236
17613
|
);
|
|
17237
|
-
if ((current.draftRevision ?? current.revision) ===
|
|
17614
|
+
if ((current.draftRevision ?? current.revision) === state2.revision) {
|
|
17238
17615
|
writeOut(
|
|
17239
17616
|
options,
|
|
17240
17617
|
values.json ? JSON.stringify(
|
|
17241
|
-
{ revision:
|
|
17618
|
+
{ revision: state2.revision, unchanged: true, leftOut: read2.leftOut },
|
|
17242
17619
|
null,
|
|
17243
17620
|
2
|
|
17244
17621
|
) : [
|
|
17245
|
-
`Unchanged ${kind.label} '${app}' at draft revision ${
|
|
17622
|
+
`Unchanged ${kind.label} '${app}' at draft revision ${state2.revision}.`,
|
|
17246
17623
|
...read2.leftOut.length === 0 ? [] : [`Left out: ${read2.leftOut.join(", ")}`]
|
|
17247
17624
|
].join("\n")
|
|
17248
17625
|
);
|
|
@@ -17412,7 +17789,8 @@ async function publish(app, values, options) {
|
|
|
17412
17789
|
outcome.run,
|
|
17413
17790
|
values.json,
|
|
17414
17791
|
options,
|
|
17415
|
-
"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
|
|
17416
17794
|
);
|
|
17417
17795
|
}
|
|
17418
17796
|
writeOut(
|
|
@@ -17431,18 +17809,18 @@ function startsWorkflows(config) {
|
|
|
17431
17809
|
return Array.isArray(manifest?.actions) && manifest.actions.some((action) => isRecord(action) && action.kind === "workflow");
|
|
17432
17810
|
}
|
|
17433
17811
|
async function status(app, directory, values, options, kind) {
|
|
17434
|
-
const
|
|
17435
|
-
if (directory !== void 0 &&
|
|
17812
|
+
const state2 = directory === void 0 ? void 0 : await readRepositoryState(directory, kind);
|
|
17813
|
+
if (directory !== void 0 && state2 === void 0) {
|
|
17436
17814
|
throw new RepositoryUsageError(
|
|
17437
17815
|
`'${directory}' holds no pulled ${kind.label} (no ${APP_STATE_FILE}).`
|
|
17438
17816
|
);
|
|
17439
17817
|
}
|
|
17440
|
-
if (
|
|
17818
|
+
if (state2 !== void 0 && state2.name !== app) {
|
|
17441
17819
|
throw new RepositoryUsageError(
|
|
17442
|
-
`'${directory}' holds the ${kind.label} '${
|
|
17820
|
+
`'${directory}' holds the ${kind.label} '${state2.name}', not '${app}'.`
|
|
17443
17821
|
);
|
|
17444
17822
|
}
|
|
17445
|
-
const target = await openRepository(options, values,
|
|
17823
|
+
const target = await openRepository(options, values, state2, kind);
|
|
17446
17824
|
const asset = await target.api.read(
|
|
17447
17825
|
(client) => client.assets.get({
|
|
17448
17826
|
params: { kind: kind.kind, name: app },
|
|
@@ -17458,7 +17836,7 @@ async function status(app, directory, values, options, kind) {
|
|
|
17458
17836
|
kind
|
|
17459
17837
|
);
|
|
17460
17838
|
const by = (revision) => revisions.find((entry) => entry.revision === revision);
|
|
17461
|
-
const local = directory === void 0 ||
|
|
17839
|
+
const local = directory === void 0 || state2 === void 0 ? void 0 : { directory, base: state2.revision, ...await localChanges2(directory, state2) };
|
|
17462
17840
|
const report = {
|
|
17463
17841
|
[kind.kind]: app,
|
|
17464
17842
|
workspaceId: target.workspaceId,
|
|
@@ -17560,19 +17938,19 @@ function formatReview(app, review) {
|
|
|
17560
17938
|
)
|
|
17561
17939
|
].join("\n");
|
|
17562
17940
|
}
|
|
17563
|
-
async function openRepository(options, values,
|
|
17941
|
+
async function openRepository(options, values, state2, kind) {
|
|
17564
17942
|
const manifest = await readManifestIfPresent(resolveWorkingDir(options));
|
|
17565
17943
|
const instance = await resolveInstance(manifest, {
|
|
17566
17944
|
...options,
|
|
17567
|
-
...options.instance === void 0 && manifest?.defaultInstance === void 0 &&
|
|
17945
|
+
...options.instance === void 0 && manifest?.defaultInstance === void 0 && state2 ? { instance: state2.instance } : {}
|
|
17568
17946
|
});
|
|
17569
17947
|
const { url } = instance;
|
|
17570
|
-
if (
|
|
17948
|
+
if (state2 !== void 0 && state2.instance !== url) {
|
|
17571
17949
|
throw new RepositoryUsageError(
|
|
17572
|
-
`The folder was pulled from ${
|
|
17950
|
+
`The folder was pulled from ${state2.instance}, and the command names ${url}. A folder belongs to one instance.`
|
|
17573
17951
|
);
|
|
17574
17952
|
}
|
|
17575
|
-
const workspaceId = values.workspace ??
|
|
17953
|
+
const workspaceId = values.workspace ?? state2?.workspaceId ?? instance.workspace;
|
|
17576
17954
|
if (workspaceId === void 0) {
|
|
17577
17955
|
throw new RepositoryUsageError(
|
|
17578
17956
|
`Name the workspace the ${kind.label} belongs to: --workspace <id>, or \`workspace: <id>\` in catalyst.yaml.`
|
|
@@ -17659,9 +18037,9 @@ function writeErr(target, text2) {
|
|
|
17659
18037
|
(target.stderr ?? ((value) => process.stderr.write(value)))(`${text2}
|
|
17660
18038
|
`);
|
|
17661
18039
|
}
|
|
17662
|
-
function pendingApproval(run, json2, options, hint) {
|
|
18040
|
+
function pendingApproval(run, json2, options, hint, note) {
|
|
17663
18041
|
if (json2) writeOut(options, JSON.stringify({ status: "pending_approval", run }, null, 2));
|
|
17664
|
-
else writeErr(options, waitingPublishLine(run, hint));
|
|
18042
|
+
else writeErr(options, waitingPublishLine(run, hint, note));
|
|
17665
18043
|
return EXIT.pending;
|
|
17666
18044
|
}
|
|
17667
18045
|
function readAudience(value) {
|
|
@@ -17722,7 +18100,7 @@ async function runFollowCommand(api, command, input, options) {
|
|
|
17722
18100
|
() => [
|
|
17723
18101
|
"ID STATUS SUMMARY DECISION",
|
|
17724
18102
|
...items.map(
|
|
17725
|
-
(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)}` : ""}`
|
|
17726
18104
|
)
|
|
17727
18105
|
].join("\n")
|
|
17728
18106
|
);
|
|
@@ -17730,6 +18108,12 @@ async function runFollowCommand(api, command, input, options) {
|
|
|
17730
18108
|
}
|
|
17731
18109
|
return EXIT2.done;
|
|
17732
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
|
+
}
|
|
17733
18117
|
|
|
17734
18118
|
// src/asset-help.ts
|
|
17735
18119
|
function formatAssetHelp(verbs) {
|
|
@@ -17849,8 +18233,8 @@ async function pushConfig(options) {
|
|
|
17849
18233
|
if (options.force) {
|
|
17850
18234
|
throw new Error(FORCE_REFUSED_MESSAGE);
|
|
17851
18235
|
}
|
|
17852
|
-
const
|
|
17853
|
-
const baseline =
|
|
18236
|
+
const state2 = await readStateFile(resolve6(workingDir, STATE_FILENAME));
|
|
18237
|
+
const baseline = state2.instances[instance.key] ?? {
|
|
17854
18238
|
lastPulledVersion: 0,
|
|
17855
18239
|
assets: {},
|
|
17856
18240
|
defaultAgentName: null
|
|
@@ -18274,7 +18658,10 @@ async function publishDrafts(api, drafts, input) {
|
|
|
18274
18658
|
return 1;
|
|
18275
18659
|
}
|
|
18276
18660
|
if (outcome.status === "pending_approval") {
|
|
18277
|
-
writeError(
|
|
18661
|
+
writeError(
|
|
18662
|
+
options,
|
|
18663
|
+
`${draft.key}: ${waitingPublishLine(outcome.run, void 0, OVERTAKEN_LINE)}`
|
|
18664
|
+
);
|
|
18278
18665
|
unpublished(index + 1);
|
|
18279
18666
|
return 3;
|
|
18280
18667
|
}
|
|
@@ -18660,9 +19047,9 @@ function filesRead(session2, from, files) {
|
|
|
18660
19047
|
].join("\n")
|
|
18661
19048
|
);
|
|
18662
19049
|
}
|
|
18663
|
-
function settle(session2, outcome, lines, approvalHint) {
|
|
19050
|
+
function settle(session2, outcome, lines, approvalHint, waitingNote) {
|
|
18664
19051
|
if (outcome.status === "pending_approval") {
|
|
18665
|
-
const text2 = waitingPublishLine(outcome.run, approvalHint);
|
|
19052
|
+
const text2 = waitingPublishLine(outcome.run, approvalHint, waitingNote);
|
|
18666
19053
|
if (session2.values.json)
|
|
18667
19054
|
writeOutput(
|
|
18668
19055
|
session2.options,
|
|
@@ -19241,6 +19628,7 @@ async function guardrailDryRunBeforePublish(session2, name2, revision) {
|
|
|
19241
19628
|
}
|
|
19242
19629
|
|
|
19243
19630
|
// src/asset-verbs/publish.ts
|
|
19631
|
+
var ALREADY_LIVE = /* @__PURE__ */ Symbol("already live");
|
|
19244
19632
|
var publishVerb = {
|
|
19245
19633
|
usage: "publish <name> --revision <n> [--yes] [--confirm <blocked>]",
|
|
19246
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",
|
|
@@ -19317,10 +19705,21 @@ var publishVerb = {
|
|
|
19317
19705
|
}),
|
|
19318
19706
|
"It may have been applied: run 'show' before sending it again."
|
|
19319
19707
|
).catch((error) => {
|
|
19708
|
+
if (isAlreadyLive(error)) return ALREADY_LIVE;
|
|
19320
19709
|
const hint = agent ? agentPublishRefusalHint(error) : void 0;
|
|
19321
19710
|
if (hint === void 0) throw error;
|
|
19322
19711
|
throw new ExplainedRefusal(error, hint);
|
|
19323
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
|
+
}
|
|
19324
19723
|
return settle(
|
|
19325
19724
|
session2,
|
|
19326
19725
|
outcome,
|
|
@@ -19332,7 +19731,8 @@ var publishVerb = {
|
|
|
19332
19731
|
// An agent's first version without a draft replaces nothing: it is offered as made.
|
|
19333
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}`}.`
|
|
19334
19733
|
],
|
|
19335
|
-
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
|
|
19336
19736
|
);
|
|
19337
19737
|
};
|
|
19338
19738
|
}
|
|
@@ -19617,24 +20017,37 @@ async function setDefault(api, kind, name2, scope, defaultOf) {
|
|
|
19617
20017
|
}
|
|
19618
20018
|
|
|
19619
20019
|
// src/asset-verbs/set-availability.ts
|
|
20020
|
+
function isAvailabilityMode(mode) {
|
|
20021
|
+
return AGENT_AVAILABILITY_MODES.some((known) => known === mode);
|
|
20022
|
+
}
|
|
19620
20023
|
var setAvailabilityVerb = {
|
|
19621
|
-
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>]...",
|
|
19622
20025
|
summary: "Set the workspaces one asset is offered in (assets.set_availability)",
|
|
19623
20026
|
named: true,
|
|
19624
20027
|
options: {
|
|
19625
20028
|
mode: { type: "string" },
|
|
19626
20029
|
personal: { type: "boolean", default: false },
|
|
19627
|
-
"available-in": { type: "string", multiple: true }
|
|
20030
|
+
"available-in": { type: "string", multiple: true },
|
|
20031
|
+
except: { type: "string", multiple: true }
|
|
19628
20032
|
},
|
|
19629
20033
|
prepare: (values, name2) => {
|
|
19630
|
-
const
|
|
19631
|
-
if (mode
|
|
19632
|
-
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.");
|
|
19633
20046
|
}
|
|
19634
20047
|
const body = {
|
|
19635
|
-
mode
|
|
20048
|
+
mode,
|
|
19636
20049
|
personalWorkspaces: values.personal,
|
|
19637
|
-
collaborationWorkspaceIds: values["available-in"] ?? []
|
|
20050
|
+
collaborationWorkspaceIds: (mode === "all_except" ? values.except : values["available-in"]) ?? []
|
|
19638
20051
|
};
|
|
19639
20052
|
return async (session2) => {
|
|
19640
20053
|
const outcome = await setAvailability(
|
|
@@ -19645,7 +20058,7 @@ var setAvailabilityVerb = {
|
|
|
19645
20058
|
session2.scope
|
|
19646
20059
|
);
|
|
19647
20060
|
return settle(session2, outcome, (output) => [
|
|
19648
|
-
`${session2.kind.kind} '${name2}' is offered in ${output
|
|
20061
|
+
`${session2.kind.kind} '${name2}' is offered in ${availabilityPhrase(output)}.`
|
|
19649
20062
|
]);
|
|
19650
20063
|
};
|
|
19651
20064
|
}
|
|
@@ -20136,6 +20549,23 @@ async function setupCommand(options) {
|
|
|
20136
20549
|
return 1;
|
|
20137
20550
|
}
|
|
20138
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
|
+
}
|
|
20139
20569
|
var NOT_A_FILE = /* @__PURE__ */ Symbol("not a file");
|
|
20140
20570
|
async function readSkillFile(path) {
|
|
20141
20571
|
const entry = await lstat4(path).catch((error) => {
|
|
@@ -21014,7 +21444,7 @@ import yaml7 from "js-yaml";
|
|
|
21014
21444
|
import { readFile as readFile10 } from "fs/promises";
|
|
21015
21445
|
import { basename as basename5, resolve as resolve11 } from "path";
|
|
21016
21446
|
import { parseArgs as parseArgs5 } from "util";
|
|
21017
|
-
import { z as
|
|
21447
|
+
import { z as z71 } from "zod";
|
|
21018
21448
|
|
|
21019
21449
|
// src/connection-sign-in.ts
|
|
21020
21450
|
import { setTimeout as defaultSleep3 } from "timers/promises";
|
|
@@ -21143,11 +21573,11 @@ async function readSecret(input, prompt) {
|
|
|
21143
21573
|
}
|
|
21144
21574
|
|
|
21145
21575
|
// src/operation-commands.ts
|
|
21146
|
-
var requestSchema =
|
|
21147
|
-
params:
|
|
21148
|
-
query:
|
|
21149
|
-
body:
|
|
21150
|
-
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()
|
|
21151
21581
|
});
|
|
21152
21582
|
var UsageError2 = class extends Error {
|
|
21153
21583
|
};
|
|
@@ -21256,7 +21686,7 @@ async function runOperationCommand(argv, base) {
|
|
|
21256
21686
|
secret = value;
|
|
21257
21687
|
if (value.length === 0) throw new UsageError2("The secret must not be empty.");
|
|
21258
21688
|
if (values.test) {
|
|
21259
|
-
const
|
|
21689
|
+
const state3 = await api2.change(
|
|
21260
21690
|
(client, idempotencyKey2) => client.connections.set_test_credential({
|
|
21261
21691
|
params: { name: connectionName },
|
|
21262
21692
|
body: {
|
|
@@ -21277,10 +21707,10 @@ async function runOperationCommand(argv, base) {
|
|
|
21277
21707
|
);
|
|
21278
21708
|
return testCredential;
|
|
21279
21709
|
});
|
|
21280
|
-
writeOutput(options, JSON.stringify(
|
|
21710
|
+
writeOutput(options, JSON.stringify(state3, null, 2));
|
|
21281
21711
|
return 0;
|
|
21282
21712
|
}
|
|
21283
|
-
const
|
|
21713
|
+
const state2 = await api2.change(
|
|
21284
21714
|
(client, idempotencyKey2) => client.connections.set_secret({
|
|
21285
21715
|
params: { name: connectionName },
|
|
21286
21716
|
body: {
|
|
@@ -21296,7 +21726,7 @@ async function runOperationCommand(argv, base) {
|
|
|
21296
21726
|
throw error;
|
|
21297
21727
|
return (await api2.read((client) => client.connections.get({ params: { name: connectionName } }))).secret;
|
|
21298
21728
|
});
|
|
21299
|
-
writeOutput(options, JSON.stringify(
|
|
21729
|
+
writeOutput(options, JSON.stringify(state2, null, 2));
|
|
21300
21730
|
return 0;
|
|
21301
21731
|
}
|
|
21302
21732
|
if (verb === "connect") {
|
|
@@ -21870,7 +22300,7 @@ var initGroup = {
|
|
|
21870
22300
|
// src/knowledge-commands.ts
|
|
21871
22301
|
import { parseArgs as parseArgs10 } from "util";
|
|
21872
22302
|
import yaml11 from "js-yaml";
|
|
21873
|
-
import { z as
|
|
22303
|
+
import { z as z72 } from "zod";
|
|
21874
22304
|
var knowledgeHelpText = `Knowledge Base sources (draft changes take effect at publish):
|
|
21875
22305
|
knowledge-base source add <kb> --source <id> --connection <name> --folder <id>... [--include <glob>...] [--exclude <glob>...]
|
|
21876
22306
|
knowledge-base source list <kb>
|
|
@@ -21935,8 +22365,8 @@ async function runKnowledgeCommand(argv, base) {
|
|
|
21935
22365
|
if (command === "add" || command === "remove" || command === "list") {
|
|
21936
22366
|
const asset = await api.getAsset("knowledge_base", name2);
|
|
21937
22367
|
if (!asset) throw new Error("The Knowledge Base is not available.");
|
|
21938
|
-
const config =
|
|
21939
|
-
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 ?? []);
|
|
21940
22370
|
if (command === "list") result = sources;
|
|
21941
22371
|
else {
|
|
21942
22372
|
const remaining = sources.filter((s) => s.id !== values.source);
|
|
@@ -21974,7 +22404,7 @@ async function runKnowledgeCommand(argv, base) {
|
|
|
21974
22404
|
const output = await call2(api, apiOperations["knowledge_bases.sources"], {
|
|
21975
22405
|
params: { knowledgeBase: name2 }
|
|
21976
22406
|
});
|
|
21977
|
-
const parsed2 =
|
|
22407
|
+
const parsed2 = z72.object({ sources: z72.array(z72.object({ id: z72.string() }).passthrough()) }).parse(output);
|
|
21978
22408
|
result = {
|
|
21979
22409
|
sources: values.source ? parsed2.sources.filter((s) => s.id === values.source) : parsed2.sources
|
|
21980
22410
|
};
|
|
@@ -22004,14 +22434,14 @@ async function runKnowledgeCommand(argv, base) {
|
|
|
22004
22434
|
return 1;
|
|
22005
22435
|
}
|
|
22006
22436
|
}
|
|
22007
|
-
var reindexAnswerSchema =
|
|
22008
|
-
started:
|
|
22009
|
-
state:
|
|
22010
|
-
active:
|
|
22011
|
-
target:
|
|
22012
|
-
progress:
|
|
22013
|
-
statement:
|
|
22014
|
-
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()
|
|
22015
22445
|
}).passthrough();
|
|
22016
22446
|
async function reindex(api, name2, confirm, options, json2) {
|
|
22017
22447
|
const raw = await call2(api, apiOperations["knowledge_bases.reindex"], {
|
|
@@ -23007,10 +23437,10 @@ async function listProviders(configFlag, json2, options) {
|
|
|
23007
23437
|
}
|
|
23008
23438
|
writeOutput(options, `Model providers of ${shownPath(options.cwd, path)}:`);
|
|
23009
23439
|
for (const provider of listed) {
|
|
23010
|
-
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" : ""}`;
|
|
23011
23441
|
writeOutput(
|
|
23012
23442
|
options,
|
|
23013
|
-
` ${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}`
|
|
23014
23444
|
);
|
|
23015
23445
|
}
|
|
23016
23446
|
return 0;
|
|
@@ -23589,12 +24019,22 @@ async function runCli(argv, runtime = {}) {
|
|
|
23589
24019
|
return group.run(argv, { ...runtime, cwd: runtime.cwd ?? process.cwd(), stdout, stderr });
|
|
23590
24020
|
}
|
|
23591
24021
|
var entryPath = process.argv[1];
|
|
23592
|
-
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));
|
|
23593
24032
|
process.exitCode = await runCli(process.argv.slice(2));
|
|
23594
24033
|
}
|
|
23595
24034
|
export {
|
|
23596
24035
|
ApiKeyExchangeError,
|
|
23597
24036
|
CANONICAL_FORM_VERSION,
|
|
24037
|
+
CliVersionError,
|
|
23598
24038
|
ConfigApiError,
|
|
23599
24039
|
MANIFEST_FILENAME,
|
|
23600
24040
|
STATE_FILENAME,
|
|
@@ -23611,11 +24051,13 @@ export {
|
|
|
23611
24051
|
createSkillFileDiff,
|
|
23612
24052
|
createUnifiedDiff,
|
|
23613
24053
|
diffConfig,
|
|
24054
|
+
enableSelfUpdate,
|
|
23614
24055
|
guardrailAssetPath,
|
|
23615
24056
|
instanceFetch,
|
|
23616
24057
|
listConfig,
|
|
23617
24058
|
matchManifestFiles,
|
|
23618
24059
|
matchesManifestPath,
|
|
24060
|
+
npmCommand,
|
|
23619
24061
|
parseAgentYaml,
|
|
23620
24062
|
parseManifest,
|
|
23621
24063
|
parseSkillFile,
|
|
@@ -23628,6 +24070,8 @@ export {
|
|
|
23628
24070
|
readStateFile,
|
|
23629
24071
|
readWorkingCopy,
|
|
23630
24072
|
redactSecret,
|
|
24073
|
+
refreshWrittenSkills,
|
|
24074
|
+
releaseVersionOf,
|
|
23631
24075
|
removeStaleManifestAssets,
|
|
23632
24076
|
renderCatalystSkill,
|
|
23633
24077
|
resolveInstance,
|
|
@@ -23641,6 +24085,7 @@ export {
|
|
|
23641
24085
|
skillAssetPath,
|
|
23642
24086
|
toConfigApiError,
|
|
23643
24087
|
updateManifestDefaultAgent,
|
|
24088
|
+
updateToServerVersion,
|
|
23644
24089
|
validateConfig,
|
|
23645
24090
|
walkFiles,
|
|
23646
24091
|
writeStateFile
|