sim 2.2.18-preview.244.1 → 2.2.18-preview.246.1
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 +1 -0
- package/dist/commands/protocol/knowledge-import.d.ts +2 -0
- package/dist/generated/v2-api.d.ts +298 -0
- package/dist/index.js +207 -25
- package/dist/program.d.ts +1 -1
- package/dist/runtime.js +207 -25
- package/dist/transfer/import-watch.d.ts +7 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -236,6 +236,7 @@ The commands you will use most often are:
|
|
|
236
236
|
| Search knowledge bases | `sim knowledge search --query "refund policy" --kb <knowledgeBaseId>` |
|
|
237
237
|
| Upload a knowledge document | `sim knowledge documents upload <knowledgeBaseId> ./handbook.pdf` |
|
|
238
238
|
| Export a knowledge base | `sim knowledge export <knowledgeBaseId> -o ./kb.simkb.zip` |
|
|
239
|
+
| Import a knowledge base | `sim knowledge import ./kb.simkb.zip` |
|
|
239
240
|
| Manage integration credentials | `sim credentials --help` |
|
|
240
241
|
| Manage workspace secrets | `sim secrets list`, `sim secrets set <name>` |
|
|
241
242
|
|
|
@@ -769,6 +769,38 @@ type BulkUpdateTableRowsResponseRef0 = {
|
|
|
769
769
|
export type BulkUpdateTableRowsResponse = {
|
|
770
770
|
data: BulkUpdateTableRowsResponseRef0;
|
|
771
771
|
};
|
|
772
|
+
/** `DELETE /api/v2/knowledge/imports/[importId]` */
|
|
773
|
+
export type CancelKnowledgeImportParams = {
|
|
774
|
+
importId: string;
|
|
775
|
+
};
|
|
776
|
+
export type CancelKnowledgeImportQuery = {
|
|
777
|
+
workspaceId: string;
|
|
778
|
+
};
|
|
779
|
+
export type CancelKnowledgeImportHeaders = {
|
|
780
|
+
'upload-token'?: string;
|
|
781
|
+
};
|
|
782
|
+
type CancelKnowledgeImportResponseRef0 = {
|
|
783
|
+
filename: string;
|
|
784
|
+
message: string;
|
|
785
|
+
};
|
|
786
|
+
type CancelKnowledgeImportResponseRef1 = {
|
|
787
|
+
id: string;
|
|
788
|
+
workspaceId: string;
|
|
789
|
+
status: 'uploading' | 'processing' | 'completed' | 'failed' | 'canceled' | 'expired';
|
|
790
|
+
knowledgeBaseId: string | null;
|
|
791
|
+
documentsTotal: number;
|
|
792
|
+
documentsImported: number;
|
|
793
|
+
documentsFailed: number;
|
|
794
|
+
vectorsReused: boolean;
|
|
795
|
+
failures: Array<CancelKnowledgeImportResponseRef0>;
|
|
796
|
+
error: string | null;
|
|
797
|
+
createdAt: string;
|
|
798
|
+
updatedAt: string;
|
|
799
|
+
completedAt: string | null;
|
|
800
|
+
};
|
|
801
|
+
export type CancelKnowledgeImportResponse = {
|
|
802
|
+
data: CancelKnowledgeImportResponseRef1;
|
|
803
|
+
};
|
|
772
804
|
/** `POST /api/v2/organizations/[organizationId]/access-requests/[requestId]/cancel` */
|
|
773
805
|
export type CancelOrganizationAccessRequestParams = {
|
|
774
806
|
organizationId: string;
|
|
@@ -1253,6 +1285,38 @@ type CompleteKnowledgeDocumentUploadResponseRef1 = {
|
|
|
1253
1285
|
export type CompleteKnowledgeDocumentUploadResponse = {
|
|
1254
1286
|
data: CompleteKnowledgeDocumentUploadResponseRef1;
|
|
1255
1287
|
};
|
|
1288
|
+
/** `POST /api/v2/knowledge/imports/[importId]/complete` */
|
|
1289
|
+
export type CompleteKnowledgeImportParams = {
|
|
1290
|
+
importId: string;
|
|
1291
|
+
};
|
|
1292
|
+
export type CompleteKnowledgeImportQuery = {
|
|
1293
|
+
workspaceId: string;
|
|
1294
|
+
};
|
|
1295
|
+
export type CompleteKnowledgeImportHeaders = {
|
|
1296
|
+
'upload-token': string;
|
|
1297
|
+
};
|
|
1298
|
+
type CompleteKnowledgeImportResponseRef0 = {
|
|
1299
|
+
filename: string;
|
|
1300
|
+
message: string;
|
|
1301
|
+
};
|
|
1302
|
+
type CompleteKnowledgeImportResponseRef1 = {
|
|
1303
|
+
id: string;
|
|
1304
|
+
workspaceId: string;
|
|
1305
|
+
status: 'uploading' | 'processing' | 'completed' | 'failed' | 'canceled' | 'expired';
|
|
1306
|
+
knowledgeBaseId: string | null;
|
|
1307
|
+
documentsTotal: number;
|
|
1308
|
+
documentsImported: number;
|
|
1309
|
+
documentsFailed: number;
|
|
1310
|
+
vectorsReused: boolean;
|
|
1311
|
+
failures: Array<CompleteKnowledgeImportResponseRef0>;
|
|
1312
|
+
error: string | null;
|
|
1313
|
+
createdAt: string;
|
|
1314
|
+
updatedAt: string;
|
|
1315
|
+
completedAt: string | null;
|
|
1316
|
+
};
|
|
1317
|
+
export type CompleteKnowledgeImportResponse = {
|
|
1318
|
+
data: CompleteKnowledgeImportResponseRef1;
|
|
1319
|
+
};
|
|
1256
1320
|
/** `POST /api/v2/projects/[projectId]/files/uploads/[uploadId]/complete` */
|
|
1257
1321
|
export type CompleteProjectFileUploadParams = {
|
|
1258
1322
|
projectId: string;
|
|
@@ -1828,6 +1892,82 @@ type CreateKnowledgeFolderResponseRef0 = {
|
|
|
1828
1892
|
export type CreateKnowledgeFolderResponse = {
|
|
1829
1893
|
data: CreateKnowledgeFolderResponseRef0;
|
|
1830
1894
|
};
|
|
1895
|
+
/** `POST /api/v2/knowledge/imports` */
|
|
1896
|
+
export type CreateKnowledgeImportQuery = Record<string, unknown>;
|
|
1897
|
+
type CreateKnowledgeImportBodyRef0 = {
|
|
1898
|
+
type: 'upload';
|
|
1899
|
+
name: string;
|
|
1900
|
+
contentType: string;
|
|
1901
|
+
size: number;
|
|
1902
|
+
};
|
|
1903
|
+
export type CreateKnowledgeImportBody = {
|
|
1904
|
+
workspaceId: string;
|
|
1905
|
+
name?: string;
|
|
1906
|
+
source: CreateKnowledgeImportBodyRef0;
|
|
1907
|
+
};
|
|
1908
|
+
type CreateKnowledgeImportResponseRef0 = {
|
|
1909
|
+
filename: string;
|
|
1910
|
+
message: string;
|
|
1911
|
+
};
|
|
1912
|
+
type CreateKnowledgeImportResponseRef1 = {
|
|
1913
|
+
id: string;
|
|
1914
|
+
workspaceId: string;
|
|
1915
|
+
status: 'uploading' | 'processing' | 'completed' | 'failed' | 'canceled' | 'expired';
|
|
1916
|
+
knowledgeBaseId: string | null;
|
|
1917
|
+
documentsTotal: number;
|
|
1918
|
+
documentsImported: number;
|
|
1919
|
+
documentsFailed: number;
|
|
1920
|
+
vectorsReused: boolean;
|
|
1921
|
+
failures: Array<CreateKnowledgeImportResponseRef0>;
|
|
1922
|
+
error: string | null;
|
|
1923
|
+
createdAt: string;
|
|
1924
|
+
updatedAt: string;
|
|
1925
|
+
completedAt: string | null;
|
|
1926
|
+
};
|
|
1927
|
+
type CreateKnowledgeImportResponseRef2 = {
|
|
1928
|
+
method: 'put';
|
|
1929
|
+
url: string;
|
|
1930
|
+
headers: Record<string, string>;
|
|
1931
|
+
expiresAt: string;
|
|
1932
|
+
};
|
|
1933
|
+
type CreateKnowledgeImportResponseRef3 = {
|
|
1934
|
+
method: 'multipart';
|
|
1935
|
+
partSize: number;
|
|
1936
|
+
partCount: number;
|
|
1937
|
+
};
|
|
1938
|
+
type CreateKnowledgeImportResponseRef4 = {
|
|
1939
|
+
session: CreateKnowledgeImportResponseRef1;
|
|
1940
|
+
uploadToken: string;
|
|
1941
|
+
transfer: CreateKnowledgeImportResponseRef2 | CreateKnowledgeImportResponseRef3;
|
|
1942
|
+
};
|
|
1943
|
+
export type CreateKnowledgeImportResponse = {
|
|
1944
|
+
data: CreateKnowledgeImportResponseRef4;
|
|
1945
|
+
};
|
|
1946
|
+
/** `POST /api/v2/knowledge/imports/[importId]/parts` */
|
|
1947
|
+
export type CreateKnowledgeImportPartUrlsParams = {
|
|
1948
|
+
importId: string;
|
|
1949
|
+
};
|
|
1950
|
+
export type CreateKnowledgeImportPartUrlsQuery = {
|
|
1951
|
+
workspaceId: string;
|
|
1952
|
+
};
|
|
1953
|
+
export type CreateKnowledgeImportPartUrlsBody = {
|
|
1954
|
+
partNumbers: Array<number>;
|
|
1955
|
+
};
|
|
1956
|
+
export type CreateKnowledgeImportPartUrlsHeaders = {
|
|
1957
|
+
'upload-token': string;
|
|
1958
|
+
};
|
|
1959
|
+
type CreateKnowledgeImportPartUrlsResponseRef0 = {
|
|
1960
|
+
partNumber: number;
|
|
1961
|
+
url: string;
|
|
1962
|
+
headers: Record<string, string>;
|
|
1963
|
+
expiresAt: string;
|
|
1964
|
+
};
|
|
1965
|
+
type CreateKnowledgeImportPartUrlsResponseRef1 = {
|
|
1966
|
+
parts: Array<CreateKnowledgeImportPartUrlsResponseRef0>;
|
|
1967
|
+
};
|
|
1968
|
+
export type CreateKnowledgeImportPartUrlsResponse = {
|
|
1969
|
+
data: CreateKnowledgeImportPartUrlsResponseRef1;
|
|
1970
|
+
};
|
|
1831
1971
|
/** `POST /api/v2/knowledge/[knowledgeBaseId]/tags` */
|
|
1832
1972
|
export type CreateKnowledgeTagParams = {
|
|
1833
1973
|
knowledgeBaseId: string;
|
|
@@ -4482,6 +4622,38 @@ type GetKnowledgeDocumentResponseRef0 = {
|
|
|
4482
4622
|
export type GetKnowledgeDocumentResponse = {
|
|
4483
4623
|
data: GetKnowledgeDocumentResponseRef0;
|
|
4484
4624
|
};
|
|
4625
|
+
/** `GET /api/v2/knowledge/imports/[importId]` */
|
|
4626
|
+
export type GetKnowledgeImportParams = {
|
|
4627
|
+
importId: string;
|
|
4628
|
+
};
|
|
4629
|
+
export type GetKnowledgeImportQuery = {
|
|
4630
|
+
workspaceId: string;
|
|
4631
|
+
};
|
|
4632
|
+
export type GetKnowledgeImportHeaders = {
|
|
4633
|
+
'upload-token'?: string;
|
|
4634
|
+
};
|
|
4635
|
+
type GetKnowledgeImportResponseRef0 = {
|
|
4636
|
+
filename: string;
|
|
4637
|
+
message: string;
|
|
4638
|
+
};
|
|
4639
|
+
type GetKnowledgeImportResponseRef1 = {
|
|
4640
|
+
id: string;
|
|
4641
|
+
workspaceId: string;
|
|
4642
|
+
status: 'uploading' | 'processing' | 'completed' | 'failed' | 'canceled' | 'expired';
|
|
4643
|
+
knowledgeBaseId: string | null;
|
|
4644
|
+
documentsTotal: number;
|
|
4645
|
+
documentsImported: number;
|
|
4646
|
+
documentsFailed: number;
|
|
4647
|
+
vectorsReused: boolean;
|
|
4648
|
+
failures: Array<GetKnowledgeImportResponseRef0>;
|
|
4649
|
+
error: string | null;
|
|
4650
|
+
createdAt: string;
|
|
4651
|
+
updatedAt: string;
|
|
4652
|
+
completedAt: string | null;
|
|
4653
|
+
};
|
|
4654
|
+
export type GetKnowledgeImportResponse = {
|
|
4655
|
+
data: GetKnowledgeImportResponseRef1;
|
|
4656
|
+
};
|
|
4485
4657
|
/** `GET /api/v2/logs/[runId]` */
|
|
4486
4658
|
export type GetLogParams = {
|
|
4487
4659
|
runId: string;
|
|
@@ -4523,6 +4695,7 @@ type GetLogResponseRef1 = {
|
|
|
4523
4695
|
toolCost?: number;
|
|
4524
4696
|
};
|
|
4525
4697
|
relativeStartMs?: number;
|
|
4698
|
+
contentWithheld?: true;
|
|
4526
4699
|
toolCalls?: Array<{
|
|
4527
4700
|
id?: string;
|
|
4528
4701
|
name?: string;
|
|
@@ -6737,6 +6910,7 @@ type ListLogsResponseRef2 = {
|
|
|
6737
6910
|
toolCost?: number;
|
|
6738
6911
|
};
|
|
6739
6912
|
relativeStartMs?: number;
|
|
6913
|
+
contentWithheld?: true;
|
|
6740
6914
|
toolCalls?: Array<{
|
|
6741
6915
|
id?: string;
|
|
6742
6916
|
name?: string;
|
|
@@ -12009,6 +12183,29 @@ export declare const V2_OPERATIONS: {
|
|
|
12009
12183
|
};
|
|
12010
12184
|
};
|
|
12011
12185
|
};
|
|
12186
|
+
readonly cancelKnowledgeImport: {
|
|
12187
|
+
readonly method: 'DELETE';
|
|
12188
|
+
readonly path: '/api/v2/knowledge/imports/[importId]';
|
|
12189
|
+
readonly pathParams: readonly ['importId'];
|
|
12190
|
+
readonly pathParamDocs: {
|
|
12191
|
+
readonly importId: 'Unique knowledge-base import identifier.';
|
|
12192
|
+
};
|
|
12193
|
+
readonly responseMode: 'json';
|
|
12194
|
+
readonly summary: 'Cancel knowledge base import';
|
|
12195
|
+
readonly query: {
|
|
12196
|
+
readonly workspaceId: {
|
|
12197
|
+
readonly kind: 'string';
|
|
12198
|
+
readonly required: true;
|
|
12199
|
+
readonly describe: 'Workspace that owns the import.';
|
|
12200
|
+
};
|
|
12201
|
+
};
|
|
12202
|
+
readonly headers: {
|
|
12203
|
+
readonly 'upload-token': {
|
|
12204
|
+
readonly kind: 'string';
|
|
12205
|
+
readonly describe: 'Signed upload control token returned when the import was created; required to read or cancel the import before its upload completes.';
|
|
12206
|
+
};
|
|
12207
|
+
};
|
|
12208
|
+
};
|
|
12012
12209
|
readonly cancelOrganizationAccessRequest: {
|
|
12013
12210
|
readonly method: 'POST';
|
|
12014
12211
|
readonly path: '/api/v2/organizations/[organizationId]/access-requests/[requestId]/cancel';
|
|
@@ -12236,6 +12433,30 @@ export declare const V2_OPERATIONS: {
|
|
|
12236
12433
|
};
|
|
12237
12434
|
};
|
|
12238
12435
|
};
|
|
12436
|
+
readonly completeKnowledgeImport: {
|
|
12437
|
+
readonly method: 'POST';
|
|
12438
|
+
readonly path: '/api/v2/knowledge/imports/[importId]/complete';
|
|
12439
|
+
readonly pathParams: readonly ['importId'];
|
|
12440
|
+
readonly pathParamDocs: {
|
|
12441
|
+
readonly importId: 'Unique knowledge-base import identifier.';
|
|
12442
|
+
};
|
|
12443
|
+
readonly responseMode: 'json';
|
|
12444
|
+
readonly summary: 'Complete knowledge base import upload';
|
|
12445
|
+
readonly query: {
|
|
12446
|
+
readonly workspaceId: {
|
|
12447
|
+
readonly kind: 'string';
|
|
12448
|
+
readonly required: true;
|
|
12449
|
+
readonly describe: 'Workspace that owns the import.';
|
|
12450
|
+
};
|
|
12451
|
+
};
|
|
12452
|
+
readonly headers: {
|
|
12453
|
+
readonly 'upload-token': {
|
|
12454
|
+
readonly kind: 'string';
|
|
12455
|
+
readonly required: true;
|
|
12456
|
+
readonly describe: 'Signed upload control token returned when the upload session was created.';
|
|
12457
|
+
};
|
|
12458
|
+
};
|
|
12459
|
+
};
|
|
12239
12460
|
readonly completeProjectFileUpload: {
|
|
12240
12461
|
readonly method: 'POST';
|
|
12241
12462
|
readonly path: '/api/v2/projects/[projectId]/files/uploads/[uploadId]/complete';
|
|
@@ -12674,6 +12895,60 @@ export declare const V2_OPERATIONS: {
|
|
|
12674
12895
|
};
|
|
12675
12896
|
};
|
|
12676
12897
|
};
|
|
12898
|
+
readonly createKnowledgeImport: {
|
|
12899
|
+
readonly method: 'POST';
|
|
12900
|
+
readonly path: '/api/v2/knowledge/imports';
|
|
12901
|
+
readonly pathParams: readonly [];
|
|
12902
|
+
readonly responseMode: 'json';
|
|
12903
|
+
readonly summary: 'Create knowledge base import';
|
|
12904
|
+
readonly body: {
|
|
12905
|
+
readonly workspaceId: {
|
|
12906
|
+
readonly kind: 'string';
|
|
12907
|
+
readonly required: true;
|
|
12908
|
+
readonly describe: 'Workspace in which to create the knowledge base.';
|
|
12909
|
+
};
|
|
12910
|
+
readonly name: {
|
|
12911
|
+
readonly kind: 'string';
|
|
12912
|
+
readonly describe: "Name for the new knowledge base; defaults to the bundle's own name.";
|
|
12913
|
+
};
|
|
12914
|
+
readonly source: {
|
|
12915
|
+
readonly kind: 'object';
|
|
12916
|
+
readonly required: true;
|
|
12917
|
+
readonly describe: 'Bundle archive uploaded through signed transfer instructions.';
|
|
12918
|
+
};
|
|
12919
|
+
};
|
|
12920
|
+
};
|
|
12921
|
+
readonly createKnowledgeImportPartUrls: {
|
|
12922
|
+
readonly method: 'POST';
|
|
12923
|
+
readonly path: '/api/v2/knowledge/imports/[importId]/parts';
|
|
12924
|
+
readonly pathParams: readonly ['importId'];
|
|
12925
|
+
readonly pathParamDocs: {
|
|
12926
|
+
readonly importId: 'Unique knowledge-base import identifier.';
|
|
12927
|
+
};
|
|
12928
|
+
readonly responseMode: 'json';
|
|
12929
|
+
readonly summary: 'Create knowledge base import part URLs';
|
|
12930
|
+
readonly query: {
|
|
12931
|
+
readonly workspaceId: {
|
|
12932
|
+
readonly kind: 'string';
|
|
12933
|
+
readonly required: true;
|
|
12934
|
+
readonly describe: 'Workspace that owns the import.';
|
|
12935
|
+
};
|
|
12936
|
+
};
|
|
12937
|
+
readonly body: {
|
|
12938
|
+
readonly partNumbers: {
|
|
12939
|
+
readonly kind: 'array';
|
|
12940
|
+
readonly required: true;
|
|
12941
|
+
readonly describe: 'Multipart part numbers for which signed URLs should be created.';
|
|
12942
|
+
};
|
|
12943
|
+
};
|
|
12944
|
+
readonly headers: {
|
|
12945
|
+
readonly 'upload-token': {
|
|
12946
|
+
readonly kind: 'string';
|
|
12947
|
+
readonly required: true;
|
|
12948
|
+
readonly describe: 'Signed upload control token returned when the upload session was created.';
|
|
12949
|
+
};
|
|
12950
|
+
};
|
|
12951
|
+
};
|
|
12677
12952
|
readonly createKnowledgeTag: {
|
|
12678
12953
|
readonly method: 'POST';
|
|
12679
12954
|
readonly path: '/api/v2/knowledge/[knowledgeBaseId]/tags';
|
|
@@ -14655,6 +14930,29 @@ export declare const V2_OPERATIONS: {
|
|
|
14655
14930
|
};
|
|
14656
14931
|
};
|
|
14657
14932
|
};
|
|
14933
|
+
readonly getKnowledgeImport: {
|
|
14934
|
+
readonly method: 'GET';
|
|
14935
|
+
readonly path: '/api/v2/knowledge/imports/[importId]';
|
|
14936
|
+
readonly pathParams: readonly ['importId'];
|
|
14937
|
+
readonly pathParamDocs: {
|
|
14938
|
+
readonly importId: 'Unique knowledge-base import identifier.';
|
|
14939
|
+
};
|
|
14940
|
+
readonly responseMode: 'json';
|
|
14941
|
+
readonly summary: 'Get knowledge base import';
|
|
14942
|
+
readonly query: {
|
|
14943
|
+
readonly workspaceId: {
|
|
14944
|
+
readonly kind: 'string';
|
|
14945
|
+
readonly required: true;
|
|
14946
|
+
readonly describe: 'Workspace that owns the import.';
|
|
14947
|
+
};
|
|
14948
|
+
};
|
|
14949
|
+
readonly headers: {
|
|
14950
|
+
readonly 'upload-token': {
|
|
14951
|
+
readonly kind: 'string';
|
|
14952
|
+
readonly describe: 'Signed upload control token returned when the import was created; required to read or cancel the import before its upload completes.';
|
|
14953
|
+
};
|
|
14954
|
+
};
|
|
14955
|
+
};
|
|
14658
14956
|
readonly getLog: {
|
|
14659
14957
|
readonly method: 'GET';
|
|
14660
14958
|
readonly path: '/api/v2/logs/[runId]';
|
package/dist/index.js
CHANGED
|
@@ -9901,6 +9901,23 @@ var V2_OPERATIONS = {
|
|
|
9901
9901
|
}
|
|
9902
9902
|
}
|
|
9903
9903
|
},
|
|
9904
|
+
cancelKnowledgeImport: {
|
|
9905
|
+
method: "DELETE",
|
|
9906
|
+
path: "/api/v2/knowledge/imports/[importId]",
|
|
9907
|
+
pathParams: ["importId"],
|
|
9908
|
+
pathParamDocs: { importId: "Unique knowledge-base import identifier." },
|
|
9909
|
+
responseMode: "json",
|
|
9910
|
+
summary: "Cancel knowledge base import",
|
|
9911
|
+
query: {
|
|
9912
|
+
workspaceId: { kind: "string", required: true, describe: "Workspace that owns the import." }
|
|
9913
|
+
},
|
|
9914
|
+
headers: {
|
|
9915
|
+
"upload-token": {
|
|
9916
|
+
kind: "string",
|
|
9917
|
+
describe: "Signed upload control token returned when the import was created; required to read or cancel the import before its upload completes."
|
|
9918
|
+
}
|
|
9919
|
+
}
|
|
9920
|
+
},
|
|
9904
9921
|
cancelOrganizationAccessRequest: {
|
|
9905
9922
|
method: "POST",
|
|
9906
9923
|
path: "/api/v2/organizations/[organizationId]/access-requests/[requestId]/cancel",
|
|
@@ -10102,6 +10119,24 @@ var V2_OPERATIONS = {
|
|
|
10102
10119
|
}
|
|
10103
10120
|
}
|
|
10104
10121
|
},
|
|
10122
|
+
completeKnowledgeImport: {
|
|
10123
|
+
method: "POST",
|
|
10124
|
+
path: "/api/v2/knowledge/imports/[importId]/complete",
|
|
10125
|
+
pathParams: ["importId"],
|
|
10126
|
+
pathParamDocs: { importId: "Unique knowledge-base import identifier." },
|
|
10127
|
+
responseMode: "json",
|
|
10128
|
+
summary: "Complete knowledge base import upload",
|
|
10129
|
+
query: {
|
|
10130
|
+
workspaceId: { kind: "string", required: true, describe: "Workspace that owns the import." }
|
|
10131
|
+
},
|
|
10132
|
+
headers: {
|
|
10133
|
+
"upload-token": {
|
|
10134
|
+
kind: "string",
|
|
10135
|
+
required: true,
|
|
10136
|
+
describe: "Signed upload control token returned when the upload session was created."
|
|
10137
|
+
}
|
|
10138
|
+
}
|
|
10139
|
+
},
|
|
10105
10140
|
completeProjectFileUpload: {
|
|
10106
10141
|
method: "POST",
|
|
10107
10142
|
path: "/api/v2/projects/[projectId]/files/uploads/[uploadId]/complete",
|
|
@@ -10473,6 +10508,54 @@ var V2_OPERATIONS = {
|
|
|
10473
10508
|
path: { kind: "string", required: true, describe: "Path of the folder to create." }
|
|
10474
10509
|
}
|
|
10475
10510
|
},
|
|
10511
|
+
createKnowledgeImport: {
|
|
10512
|
+
method: "POST",
|
|
10513
|
+
path: "/api/v2/knowledge/imports",
|
|
10514
|
+
pathParams: [],
|
|
10515
|
+
responseMode: "json",
|
|
10516
|
+
summary: "Create knowledge base import",
|
|
10517
|
+
body: {
|
|
10518
|
+
workspaceId: {
|
|
10519
|
+
kind: "string",
|
|
10520
|
+
required: true,
|
|
10521
|
+
describe: "Workspace in which to create the knowledge base."
|
|
10522
|
+
},
|
|
10523
|
+
name: {
|
|
10524
|
+
kind: "string",
|
|
10525
|
+
describe: "Name for the new knowledge base; defaults to the bundle's own name."
|
|
10526
|
+
},
|
|
10527
|
+
source: {
|
|
10528
|
+
kind: "object",
|
|
10529
|
+
required: true,
|
|
10530
|
+
describe: "Bundle archive uploaded through signed transfer instructions."
|
|
10531
|
+
}
|
|
10532
|
+
}
|
|
10533
|
+
},
|
|
10534
|
+
createKnowledgeImportPartUrls: {
|
|
10535
|
+
method: "POST",
|
|
10536
|
+
path: "/api/v2/knowledge/imports/[importId]/parts",
|
|
10537
|
+
pathParams: ["importId"],
|
|
10538
|
+
pathParamDocs: { importId: "Unique knowledge-base import identifier." },
|
|
10539
|
+
responseMode: "json",
|
|
10540
|
+
summary: "Create knowledge base import part URLs",
|
|
10541
|
+
query: {
|
|
10542
|
+
workspaceId: { kind: "string", required: true, describe: "Workspace that owns the import." }
|
|
10543
|
+
},
|
|
10544
|
+
body: {
|
|
10545
|
+
partNumbers: {
|
|
10546
|
+
kind: "array",
|
|
10547
|
+
required: true,
|
|
10548
|
+
describe: "Multipart part numbers for which signed URLs should be created."
|
|
10549
|
+
}
|
|
10550
|
+
},
|
|
10551
|
+
headers: {
|
|
10552
|
+
"upload-token": {
|
|
10553
|
+
kind: "string",
|
|
10554
|
+
required: true,
|
|
10555
|
+
describe: "Signed upload control token returned when the upload session was created."
|
|
10556
|
+
}
|
|
10557
|
+
}
|
|
10558
|
+
},
|
|
10476
10559
|
createKnowledgeTag: {
|
|
10477
10560
|
method: "POST",
|
|
10478
10561
|
path: "/api/v2/knowledge/[knowledgeBaseId]/tags",
|
|
@@ -12195,6 +12278,23 @@ var V2_OPERATIONS = {
|
|
|
12195
12278
|
}
|
|
12196
12279
|
}
|
|
12197
12280
|
},
|
|
12281
|
+
getKnowledgeImport: {
|
|
12282
|
+
method: "GET",
|
|
12283
|
+
path: "/api/v2/knowledge/imports/[importId]",
|
|
12284
|
+
pathParams: ["importId"],
|
|
12285
|
+
pathParamDocs: { importId: "Unique knowledge-base import identifier." },
|
|
12286
|
+
responseMode: "json",
|
|
12287
|
+
summary: "Get knowledge base import",
|
|
12288
|
+
query: {
|
|
12289
|
+
workspaceId: { kind: "string", required: true, describe: "Workspace that owns the import." }
|
|
12290
|
+
},
|
|
12291
|
+
headers: {
|
|
12292
|
+
"upload-token": {
|
|
12293
|
+
kind: "string",
|
|
12294
|
+
describe: "Signed upload control token returned when the import was created; required to read or cancel the import before its upload completes."
|
|
12295
|
+
}
|
|
12296
|
+
}
|
|
12297
|
+
},
|
|
12198
12298
|
getLog: {
|
|
12199
12299
|
method: "GET",
|
|
12200
12300
|
path: "/api/v2/logs/[runId]",
|
|
@@ -20666,6 +20766,15 @@ var CLI_CONTRACT = {
|
|
|
20666
20766
|
createKnowledgeDocumentUploadPartUrls: { hidden: true },
|
|
20667
20767
|
completeKnowledgeDocumentUpload: { hidden: true },
|
|
20668
20768
|
abortKnowledgeDocumentUpload: { hidden: true },
|
|
20769
|
+
createKnowledgeImport: { hidden: true },
|
|
20770
|
+
createKnowledgeImportPartUrls: { hidden: true },
|
|
20771
|
+
completeKnowledgeImport: { hidden: true },
|
|
20772
|
+
getKnowledgeImport: { flags: TRANSFER_TOKEN_OMITTED },
|
|
20773
|
+
cancelKnowledgeImport: {
|
|
20774
|
+
command: "knowledge imports cancel",
|
|
20775
|
+
flags: TRANSFER_TOKEN_OMITTED,
|
|
20776
|
+
describe: "Stop a running import"
|
|
20777
|
+
},
|
|
20669
20778
|
createFileUpload: { hidden: true },
|
|
20670
20779
|
createProjectFileUpload: { hidden: true },
|
|
20671
20780
|
getProjectFileUpload: { hidden: true },
|
|
@@ -23335,6 +23444,97 @@ function attachKnowledgeExport(knowledge) {
|
|
|
23335
23444
|
});
|
|
23336
23445
|
}
|
|
23337
23446
|
|
|
23447
|
+
// src/transfer/import-watch.ts
|
|
23448
|
+
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
23449
|
+
var IMPORT_POLL_MS = 1500;
|
|
23450
|
+
var IMPORT_SETTLED = new Set(["completed", "failed", "canceled", "expired"]);
|
|
23451
|
+
async function watchImport(job, fetchNext, progressLine) {
|
|
23452
|
+
let current = job;
|
|
23453
|
+
let reported = null;
|
|
23454
|
+
while (!IMPORT_SETTLED.has(current.status)) {
|
|
23455
|
+
await sleep2(IMPORT_POLL_MS);
|
|
23456
|
+
current = await fetchNext(current);
|
|
23457
|
+
const line = progressLine(current);
|
|
23458
|
+
if (hasProgressTerminal() && line !== reported) {
|
|
23459
|
+
reported = line;
|
|
23460
|
+
writeStderr(`\r${styles3().dim(line)}\x1B[K`);
|
|
23461
|
+
}
|
|
23462
|
+
}
|
|
23463
|
+
if (hasProgressTerminal() && reported !== null)
|
|
23464
|
+
writeStderr("\r\x1B[K");
|
|
23465
|
+
return current;
|
|
23466
|
+
}
|
|
23467
|
+
|
|
23468
|
+
// src/commands/protocol/knowledge-import.ts
|
|
23469
|
+
function importFields(job) {
|
|
23470
|
+
return {
|
|
23471
|
+
id: job.id,
|
|
23472
|
+
status: job.status,
|
|
23473
|
+
knowledgeBaseId: job.knowledgeBaseId,
|
|
23474
|
+
documentsTotal: job.documentsTotal,
|
|
23475
|
+
documentsImported: job.documentsImported,
|
|
23476
|
+
documentsFailed: job.documentsFailed,
|
|
23477
|
+
vectorsReused: job.vectorsReused,
|
|
23478
|
+
...job.failures.length > 0 ? { failures: job.failures.map(({ filename, message }) => `${filename}: ${message}`) } : {}
|
|
23479
|
+
};
|
|
23480
|
+
}
|
|
23481
|
+
function progressLine(job) {
|
|
23482
|
+
const failed = job.documentsFailed > 0 ? `, ${job.documentsFailed} failed` : "";
|
|
23483
|
+
return `${job.status}… ${job.documentsImported}/${job.documentsTotal} documents${failed}`;
|
|
23484
|
+
}
|
|
23485
|
+
function attachKnowledgeImport(knowledge) {
|
|
23486
|
+
const [importCommand, connectImport] = apiCommand(knowledge, "import", [
|
|
23487
|
+
"createKnowledgeImport",
|
|
23488
|
+
"createKnowledgeImportPartUrls",
|
|
23489
|
+
"completeKnowledgeImport",
|
|
23490
|
+
"cancelKnowledgeImport",
|
|
23491
|
+
"getKnowledgeImport"
|
|
23492
|
+
]);
|
|
23493
|
+
importCommand.argument("<path>", "Bundle archive written by `sim knowledge export`").allowExcessArguments(false).description("Create a knowledge base from an exported .simkb.zip bundle").option("--name <name>", "Name for the new knowledge base; defaults to the bundle's own name").option("--no-wait", "Return once the import is started instead of watching it").action(async (path, options) => {
|
|
23494
|
+
const { client, profile } = connectImport();
|
|
23495
|
+
const workspaceId = client.requireWorkspace();
|
|
23496
|
+
const local = await localFile(path);
|
|
23497
|
+
if (!local.name.toLowerCase().endsWith(".zip")) {
|
|
23498
|
+
throw new SimApiError("A knowledge base bundle must be a .zip archive", 0);
|
|
23499
|
+
}
|
|
23500
|
+
const started = await client.request("createKnowledgeImport", {
|
|
23501
|
+
body: {
|
|
23502
|
+
workspaceId,
|
|
23503
|
+
...options.name !== undefined ? { name: options.name } : {},
|
|
23504
|
+
source: {
|
|
23505
|
+
type: "upload",
|
|
23506
|
+
name: local.name,
|
|
23507
|
+
contentType: contentTypeFor(local.name),
|
|
23508
|
+
size: local.size
|
|
23509
|
+
}
|
|
23510
|
+
}
|
|
23511
|
+
});
|
|
23512
|
+
const job = await finishUploadSession(client, workspaceId, {
|
|
23513
|
+
operations: {
|
|
23514
|
+
parts: "createKnowledgeImportPartUrls",
|
|
23515
|
+
complete: "completeKnowledgeImport",
|
|
23516
|
+
abort: "cancelKnowledgeImport"
|
|
23517
|
+
},
|
|
23518
|
+
params: { importId: started.data.session.id },
|
|
23519
|
+
uploadToken: started.data.uploadToken,
|
|
23520
|
+
transfer: started.data.transfer,
|
|
23521
|
+
size: local.size
|
|
23522
|
+
}, path);
|
|
23523
|
+
if (!options.wait) {
|
|
23524
|
+
printProtocolResult(profile.output, importFields(job));
|
|
23525
|
+
return;
|
|
23526
|
+
}
|
|
23527
|
+
const finished = await watchImport(job, async (current) => (await client.request("getKnowledgeImport", {
|
|
23528
|
+
params: { importId: current.id },
|
|
23529
|
+
query: { workspaceId }
|
|
23530
|
+
})).data, progressLine);
|
|
23531
|
+
if (finished.status !== "completed") {
|
|
23532
|
+
throw new SimApiError(`Import ${finished.status}${finished.error ? `: ${finished.error}` : ""}`, 0);
|
|
23533
|
+
}
|
|
23534
|
+
printProtocolResult(profile.output, importFields(finished));
|
|
23535
|
+
});
|
|
23536
|
+
}
|
|
23537
|
+
|
|
23338
23538
|
// src/commands/protocol/logs-follow.ts
|
|
23339
23539
|
var DEFAULT_BACKLOG = 10;
|
|
23340
23540
|
var DEFAULT_INTERVAL_SECONDS = 3;
|
|
@@ -23688,9 +23888,6 @@ function attachResourceDirectoryCommands(group, config) {
|
|
|
23688
23888
|
}
|
|
23689
23889
|
|
|
23690
23890
|
// src/commands/protocol/tables-import.ts
|
|
23691
|
-
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
23692
|
-
var IMPORT_POLL_MS = 1500;
|
|
23693
|
-
var IMPORT_SETTLED = new Set(["completed", "failed", "canceled", "expired"]);
|
|
23694
23891
|
function tableNameFrom(fileName) {
|
|
23695
23892
|
const stem = fileName.replace(/\.[^.]+$/, "");
|
|
23696
23893
|
const cleaned = stem.replace(/[^A-Za-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
@@ -23713,7 +23910,7 @@ function rejectionFields(job) {
|
|
|
23713
23910
|
...samples.length > 0 ? { rejectedSamples: samples } : {}
|
|
23714
23911
|
};
|
|
23715
23912
|
}
|
|
23716
|
-
function
|
|
23913
|
+
function progressLine2(job) {
|
|
23717
23914
|
const rows = job.rowsRejected ?? 0;
|
|
23718
23915
|
const cells = job.cellsRejected ?? 0;
|
|
23719
23916
|
const parts = [];
|
|
@@ -23724,26 +23921,6 @@ function progressLine(job) {
|
|
|
23724
23921
|
const suffix = parts.length > 0 ? `, ${parts.join(", ")}` : "";
|
|
23725
23922
|
return `${job.status}… ${job.rowsProcessed} rows${suffix}`;
|
|
23726
23923
|
}
|
|
23727
|
-
async function watchImport(client, workspaceId, job) {
|
|
23728
|
-
let current = job;
|
|
23729
|
-
let reported = null;
|
|
23730
|
-
while (!IMPORT_SETTLED.has(current.status)) {
|
|
23731
|
-
await sleep2(IMPORT_POLL_MS);
|
|
23732
|
-
const next = await client.request("getTableImport", {
|
|
23733
|
-
params: { importId: current.id },
|
|
23734
|
-
query: { workspaceId }
|
|
23735
|
-
});
|
|
23736
|
-
current = next.data;
|
|
23737
|
-
const line = progressLine(current);
|
|
23738
|
-
if (hasProgressTerminal() && line !== reported) {
|
|
23739
|
-
reported = line;
|
|
23740
|
-
writeStderr(`\r${styles3().dim(line)}\x1B[K`);
|
|
23741
|
-
}
|
|
23742
|
-
}
|
|
23743
|
-
if (hasProgressTerminal() && reported !== null)
|
|
23744
|
-
writeStderr("\r\x1B[K");
|
|
23745
|
-
return current;
|
|
23746
|
-
}
|
|
23747
23924
|
function validateTargetOptions(options) {
|
|
23748
23925
|
const intoExisting = Boolean(options.tableId);
|
|
23749
23926
|
const misplaced = intoExisting ? [
|
|
@@ -23838,7 +24015,10 @@ function attachTableImport(tables) {
|
|
|
23838
24015
|
});
|
|
23839
24016
|
return;
|
|
23840
24017
|
}
|
|
23841
|
-
const finished = await watchImport(
|
|
24018
|
+
const finished = await watchImport(job, async (current) => (await client.request("getTableImport", {
|
|
24019
|
+
params: { importId: current.id },
|
|
24020
|
+
query: { workspaceId }
|
|
24021
|
+
})).data, progressLine2);
|
|
23842
24022
|
if (finished.status !== "completed") {
|
|
23843
24023
|
throw new SimApiError(`Import ${finished.status}${finished.error ? `: ${finished.error}` : ""}`, 0);
|
|
23844
24024
|
}
|
|
@@ -24415,6 +24595,7 @@ function attachProtocolCommands(program) {
|
|
|
24415
24595
|
const knowledge = group(program, "knowledge");
|
|
24416
24596
|
attachKnowledgeDocumentUpload(group(knowledge, "documents"));
|
|
24417
24597
|
attachKnowledgeExport(knowledge);
|
|
24598
|
+
attachKnowledgeImport(knowledge);
|
|
24418
24599
|
attachResourceDirectoryCommands(knowledge, {
|
|
24419
24600
|
kind: "knowledge",
|
|
24420
24601
|
resources: "listKnowledgeBases",
|
|
@@ -25991,6 +26172,7 @@ Examples:
|
|
|
25991
26172
|
$ sim workflows export 3a9e21d8-5f47-4c0b-b2ea-91d7c6034ef8 > wf.json
|
|
25992
26173
|
$ sim workflows import --workflow @wf.json
|
|
25993
26174
|
$ sim knowledge export 4c1b7f60-2d55-4a3e-9c18-70b6ea2f9d31 -o ./kb.simkb.zip
|
|
26175
|
+
$ sim knowledge import ./kb.simkb.zip --name "Docs (copy)"
|
|
25994
26176
|
$ sim whoami --profile dev
|
|
25995
26177
|
`;
|
|
25996
26178
|
var AGENT_DISCOVERY_NOTE = `=== AGENT COMMAND DISCOVERY ===
|
package/dist/program.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Command } from 'commander';
|
|
2
2
|
/** Root program description, shared by `--help` and the generated docs. */
|
|
3
3
|
export declare const PROGRAM_DESCRIPTION = "Talk to the Sim API from your terminal";
|
|
4
|
-
export declare const HELP_EPILOGUE = "\nProfiles work like the AWS CLI: settings live in ~/.sim/config, keys in\n~/.sim/credentials (0600), or under SIM_CONFIG_DIR when it is set. Select one\nwith -P, --profile, or SIM_PROFILE.\n\nWorkflow, knowledge-base and workspace IDs are bare UUIDs. Table IDs carry a\ntbl_ prefix and file IDs a wf_ one, so wf_ never names a workflow. An audit-log\nor custom-tool ID can open with a dash, which reads as a flag; put -- in front\nof it, as in sim audit-logs get -- -HlDcD1z76nK6R4crsUp0.\n\nExamples:\n $ sim cli search \"cancel a workflow run\" Find the command for a task\n $ sim login Authorize the default profile\n $ sim login --profile dev --endpoint http://localhost:3000\n $ sim profile add acme --workspace 7e2d9c14-6b83-4a55-8f01-c4d3e9a76b28\n $ sim workflows list\n $ sim logs list --level error --limit 20\n $ sim configure --set-output table Prefer tables over the JSON default\n $ sim --output table tables get tbl_9f3c1a05d4b7426e8c2f0917ab35de64\n $ sim knowledge search --query \"refund policy\" --kb 4c1b7f60-2d55-4a3e-9c18-70b6ea2f9d31\n $ sim workflows export 3a9e21d8-5f47-4c0b-b2ea-91d7c6034ef8 > wf.json\n $ sim workflows import --workflow @wf.json\n $ sim knowledge export 4c1b7f60-2d55-4a3e-9c18-70b6ea2f9d31 -o ./kb.simkb.zip\n $ sim whoami --profile dev\n";
|
|
4
|
+
export declare const HELP_EPILOGUE = "\nProfiles work like the AWS CLI: settings live in ~/.sim/config, keys in\n~/.sim/credentials (0600), or under SIM_CONFIG_DIR when it is set. Select one\nwith -P, --profile, or SIM_PROFILE.\n\nWorkflow, knowledge-base and workspace IDs are bare UUIDs. Table IDs carry a\ntbl_ prefix and file IDs a wf_ one, so wf_ never names a workflow. An audit-log\nor custom-tool ID can open with a dash, which reads as a flag; put -- in front\nof it, as in sim audit-logs get -- -HlDcD1z76nK6R4crsUp0.\n\nExamples:\n $ sim cli search \"cancel a workflow run\" Find the command for a task\n $ sim login Authorize the default profile\n $ sim login --profile dev --endpoint http://localhost:3000\n $ sim profile add acme --workspace 7e2d9c14-6b83-4a55-8f01-c4d3e9a76b28\n $ sim workflows list\n $ sim logs list --level error --limit 20\n $ sim configure --set-output table Prefer tables over the JSON default\n $ sim --output table tables get tbl_9f3c1a05d4b7426e8c2f0917ab35de64\n $ sim knowledge search --query \"refund policy\" --kb 4c1b7f60-2d55-4a3e-9c18-70b6ea2f9d31\n $ sim workflows export 3a9e21d8-5f47-4c0b-b2ea-91d7c6034ef8 > wf.json\n $ sim workflows import --workflow @wf.json\n $ sim knowledge export 4c1b7f60-2d55-4a3e-9c18-70b6ea2f9d31 -o ./kb.simkb.zip\n $ sim knowledge import ./kb.simkb.zip --name \"Docs (copy)\"\n $ sim whoami --profile dev\n";
|
|
5
5
|
/**
|
|
6
6
|
* Printed above group-level help when a coding agent runs the CLI.
|
|
7
7
|
*
|
package/dist/runtime.js
CHANGED
|
@@ -9950,6 +9950,23 @@ var V2_OPERATIONS = {
|
|
|
9950
9950
|
}
|
|
9951
9951
|
}
|
|
9952
9952
|
},
|
|
9953
|
+
cancelKnowledgeImport: {
|
|
9954
|
+
method: "DELETE",
|
|
9955
|
+
path: "/api/v2/knowledge/imports/[importId]",
|
|
9956
|
+
pathParams: ["importId"],
|
|
9957
|
+
pathParamDocs: { importId: "Unique knowledge-base import identifier." },
|
|
9958
|
+
responseMode: "json",
|
|
9959
|
+
summary: "Cancel knowledge base import",
|
|
9960
|
+
query: {
|
|
9961
|
+
workspaceId: { kind: "string", required: true, describe: "Workspace that owns the import." }
|
|
9962
|
+
},
|
|
9963
|
+
headers: {
|
|
9964
|
+
"upload-token": {
|
|
9965
|
+
kind: "string",
|
|
9966
|
+
describe: "Signed upload control token returned when the import was created; required to read or cancel the import before its upload completes."
|
|
9967
|
+
}
|
|
9968
|
+
}
|
|
9969
|
+
},
|
|
9953
9970
|
cancelOrganizationAccessRequest: {
|
|
9954
9971
|
method: "POST",
|
|
9955
9972
|
path: "/api/v2/organizations/[organizationId]/access-requests/[requestId]/cancel",
|
|
@@ -10151,6 +10168,24 @@ var V2_OPERATIONS = {
|
|
|
10151
10168
|
}
|
|
10152
10169
|
}
|
|
10153
10170
|
},
|
|
10171
|
+
completeKnowledgeImport: {
|
|
10172
|
+
method: "POST",
|
|
10173
|
+
path: "/api/v2/knowledge/imports/[importId]/complete",
|
|
10174
|
+
pathParams: ["importId"],
|
|
10175
|
+
pathParamDocs: { importId: "Unique knowledge-base import identifier." },
|
|
10176
|
+
responseMode: "json",
|
|
10177
|
+
summary: "Complete knowledge base import upload",
|
|
10178
|
+
query: {
|
|
10179
|
+
workspaceId: { kind: "string", required: true, describe: "Workspace that owns the import." }
|
|
10180
|
+
},
|
|
10181
|
+
headers: {
|
|
10182
|
+
"upload-token": {
|
|
10183
|
+
kind: "string",
|
|
10184
|
+
required: true,
|
|
10185
|
+
describe: "Signed upload control token returned when the upload session was created."
|
|
10186
|
+
}
|
|
10187
|
+
}
|
|
10188
|
+
},
|
|
10154
10189
|
completeProjectFileUpload: {
|
|
10155
10190
|
method: "POST",
|
|
10156
10191
|
path: "/api/v2/projects/[projectId]/files/uploads/[uploadId]/complete",
|
|
@@ -10522,6 +10557,54 @@ var V2_OPERATIONS = {
|
|
|
10522
10557
|
path: { kind: "string", required: true, describe: "Path of the folder to create." }
|
|
10523
10558
|
}
|
|
10524
10559
|
},
|
|
10560
|
+
createKnowledgeImport: {
|
|
10561
|
+
method: "POST",
|
|
10562
|
+
path: "/api/v2/knowledge/imports",
|
|
10563
|
+
pathParams: [],
|
|
10564
|
+
responseMode: "json",
|
|
10565
|
+
summary: "Create knowledge base import",
|
|
10566
|
+
body: {
|
|
10567
|
+
workspaceId: {
|
|
10568
|
+
kind: "string",
|
|
10569
|
+
required: true,
|
|
10570
|
+
describe: "Workspace in which to create the knowledge base."
|
|
10571
|
+
},
|
|
10572
|
+
name: {
|
|
10573
|
+
kind: "string",
|
|
10574
|
+
describe: "Name for the new knowledge base; defaults to the bundle's own name."
|
|
10575
|
+
},
|
|
10576
|
+
source: {
|
|
10577
|
+
kind: "object",
|
|
10578
|
+
required: true,
|
|
10579
|
+
describe: "Bundle archive uploaded through signed transfer instructions."
|
|
10580
|
+
}
|
|
10581
|
+
}
|
|
10582
|
+
},
|
|
10583
|
+
createKnowledgeImportPartUrls: {
|
|
10584
|
+
method: "POST",
|
|
10585
|
+
path: "/api/v2/knowledge/imports/[importId]/parts",
|
|
10586
|
+
pathParams: ["importId"],
|
|
10587
|
+
pathParamDocs: { importId: "Unique knowledge-base import identifier." },
|
|
10588
|
+
responseMode: "json",
|
|
10589
|
+
summary: "Create knowledge base import part URLs",
|
|
10590
|
+
query: {
|
|
10591
|
+
workspaceId: { kind: "string", required: true, describe: "Workspace that owns the import." }
|
|
10592
|
+
},
|
|
10593
|
+
body: {
|
|
10594
|
+
partNumbers: {
|
|
10595
|
+
kind: "array",
|
|
10596
|
+
required: true,
|
|
10597
|
+
describe: "Multipart part numbers for which signed URLs should be created."
|
|
10598
|
+
}
|
|
10599
|
+
},
|
|
10600
|
+
headers: {
|
|
10601
|
+
"upload-token": {
|
|
10602
|
+
kind: "string",
|
|
10603
|
+
required: true,
|
|
10604
|
+
describe: "Signed upload control token returned when the upload session was created."
|
|
10605
|
+
}
|
|
10606
|
+
}
|
|
10607
|
+
},
|
|
10525
10608
|
createKnowledgeTag: {
|
|
10526
10609
|
method: "POST",
|
|
10527
10610
|
path: "/api/v2/knowledge/[knowledgeBaseId]/tags",
|
|
@@ -12244,6 +12327,23 @@ var V2_OPERATIONS = {
|
|
|
12244
12327
|
}
|
|
12245
12328
|
}
|
|
12246
12329
|
},
|
|
12330
|
+
getKnowledgeImport: {
|
|
12331
|
+
method: "GET",
|
|
12332
|
+
path: "/api/v2/knowledge/imports/[importId]",
|
|
12333
|
+
pathParams: ["importId"],
|
|
12334
|
+
pathParamDocs: { importId: "Unique knowledge-base import identifier." },
|
|
12335
|
+
responseMode: "json",
|
|
12336
|
+
summary: "Get knowledge base import",
|
|
12337
|
+
query: {
|
|
12338
|
+
workspaceId: { kind: "string", required: true, describe: "Workspace that owns the import." }
|
|
12339
|
+
},
|
|
12340
|
+
headers: {
|
|
12341
|
+
"upload-token": {
|
|
12342
|
+
kind: "string",
|
|
12343
|
+
describe: "Signed upload control token returned when the import was created; required to read or cancel the import before its upload completes."
|
|
12344
|
+
}
|
|
12345
|
+
}
|
|
12346
|
+
},
|
|
12247
12347
|
getLog: {
|
|
12248
12348
|
method: "GET",
|
|
12249
12349
|
path: "/api/v2/logs/[runId]",
|
|
@@ -20715,6 +20815,15 @@ var CLI_CONTRACT = {
|
|
|
20715
20815
|
createKnowledgeDocumentUploadPartUrls: { hidden: true },
|
|
20716
20816
|
completeKnowledgeDocumentUpload: { hidden: true },
|
|
20717
20817
|
abortKnowledgeDocumentUpload: { hidden: true },
|
|
20818
|
+
createKnowledgeImport: { hidden: true },
|
|
20819
|
+
createKnowledgeImportPartUrls: { hidden: true },
|
|
20820
|
+
completeKnowledgeImport: { hidden: true },
|
|
20821
|
+
getKnowledgeImport: { flags: TRANSFER_TOKEN_OMITTED },
|
|
20822
|
+
cancelKnowledgeImport: {
|
|
20823
|
+
command: "knowledge imports cancel",
|
|
20824
|
+
flags: TRANSFER_TOKEN_OMITTED,
|
|
20825
|
+
describe: "Stop a running import"
|
|
20826
|
+
},
|
|
20718
20827
|
createFileUpload: { hidden: true },
|
|
20719
20828
|
createProjectFileUpload: { hidden: true },
|
|
20720
20829
|
getProjectFileUpload: { hidden: true },
|
|
@@ -23384,6 +23493,97 @@ function attachKnowledgeExport(knowledge) {
|
|
|
23384
23493
|
});
|
|
23385
23494
|
}
|
|
23386
23495
|
|
|
23496
|
+
// src/transfer/import-watch.ts
|
|
23497
|
+
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
23498
|
+
var IMPORT_POLL_MS = 1500;
|
|
23499
|
+
var IMPORT_SETTLED = new Set(["completed", "failed", "canceled", "expired"]);
|
|
23500
|
+
async function watchImport(job, fetchNext, progressLine) {
|
|
23501
|
+
let current = job;
|
|
23502
|
+
let reported = null;
|
|
23503
|
+
while (!IMPORT_SETTLED.has(current.status)) {
|
|
23504
|
+
await sleep2(IMPORT_POLL_MS);
|
|
23505
|
+
current = await fetchNext(current);
|
|
23506
|
+
const line = progressLine(current);
|
|
23507
|
+
if (hasProgressTerminal() && line !== reported) {
|
|
23508
|
+
reported = line;
|
|
23509
|
+
writeStderr(`\r${styles3().dim(line)}\x1B[K`);
|
|
23510
|
+
}
|
|
23511
|
+
}
|
|
23512
|
+
if (hasProgressTerminal() && reported !== null)
|
|
23513
|
+
writeStderr("\r\x1B[K");
|
|
23514
|
+
return current;
|
|
23515
|
+
}
|
|
23516
|
+
|
|
23517
|
+
// src/commands/protocol/knowledge-import.ts
|
|
23518
|
+
function importFields(job) {
|
|
23519
|
+
return {
|
|
23520
|
+
id: job.id,
|
|
23521
|
+
status: job.status,
|
|
23522
|
+
knowledgeBaseId: job.knowledgeBaseId,
|
|
23523
|
+
documentsTotal: job.documentsTotal,
|
|
23524
|
+
documentsImported: job.documentsImported,
|
|
23525
|
+
documentsFailed: job.documentsFailed,
|
|
23526
|
+
vectorsReused: job.vectorsReused,
|
|
23527
|
+
...job.failures.length > 0 ? { failures: job.failures.map(({ filename, message }) => `${filename}: ${message}`) } : {}
|
|
23528
|
+
};
|
|
23529
|
+
}
|
|
23530
|
+
function progressLine(job) {
|
|
23531
|
+
const failed = job.documentsFailed > 0 ? `, ${job.documentsFailed} failed` : "";
|
|
23532
|
+
return `${job.status}… ${job.documentsImported}/${job.documentsTotal} documents${failed}`;
|
|
23533
|
+
}
|
|
23534
|
+
function attachKnowledgeImport(knowledge) {
|
|
23535
|
+
const [importCommand, connectImport] = apiCommand(knowledge, "import", [
|
|
23536
|
+
"createKnowledgeImport",
|
|
23537
|
+
"createKnowledgeImportPartUrls",
|
|
23538
|
+
"completeKnowledgeImport",
|
|
23539
|
+
"cancelKnowledgeImport",
|
|
23540
|
+
"getKnowledgeImport"
|
|
23541
|
+
]);
|
|
23542
|
+
importCommand.argument("<path>", "Bundle archive written by `sim knowledge export`").allowExcessArguments(false).description("Create a knowledge base from an exported .simkb.zip bundle").option("--name <name>", "Name for the new knowledge base; defaults to the bundle's own name").option("--no-wait", "Return once the import is started instead of watching it").action(async (path, options) => {
|
|
23543
|
+
const { client, profile } = connectImport();
|
|
23544
|
+
const workspaceId = client.requireWorkspace();
|
|
23545
|
+
const local = await localFile(path);
|
|
23546
|
+
if (!local.name.toLowerCase().endsWith(".zip")) {
|
|
23547
|
+
throw new SimApiError("A knowledge base bundle must be a .zip archive", 0);
|
|
23548
|
+
}
|
|
23549
|
+
const started = await client.request("createKnowledgeImport", {
|
|
23550
|
+
body: {
|
|
23551
|
+
workspaceId,
|
|
23552
|
+
...options.name !== undefined ? { name: options.name } : {},
|
|
23553
|
+
source: {
|
|
23554
|
+
type: "upload",
|
|
23555
|
+
name: local.name,
|
|
23556
|
+
contentType: contentTypeFor(local.name),
|
|
23557
|
+
size: local.size
|
|
23558
|
+
}
|
|
23559
|
+
}
|
|
23560
|
+
});
|
|
23561
|
+
const job = await finishUploadSession(client, workspaceId, {
|
|
23562
|
+
operations: {
|
|
23563
|
+
parts: "createKnowledgeImportPartUrls",
|
|
23564
|
+
complete: "completeKnowledgeImport",
|
|
23565
|
+
abort: "cancelKnowledgeImport"
|
|
23566
|
+
},
|
|
23567
|
+
params: { importId: started.data.session.id },
|
|
23568
|
+
uploadToken: started.data.uploadToken,
|
|
23569
|
+
transfer: started.data.transfer,
|
|
23570
|
+
size: local.size
|
|
23571
|
+
}, path);
|
|
23572
|
+
if (!options.wait) {
|
|
23573
|
+
printProtocolResult(profile.output, importFields(job));
|
|
23574
|
+
return;
|
|
23575
|
+
}
|
|
23576
|
+
const finished = await watchImport(job, async (current) => (await client.request("getKnowledgeImport", {
|
|
23577
|
+
params: { importId: current.id },
|
|
23578
|
+
query: { workspaceId }
|
|
23579
|
+
})).data, progressLine);
|
|
23580
|
+
if (finished.status !== "completed") {
|
|
23581
|
+
throw new SimApiError(`Import ${finished.status}${finished.error ? `: ${finished.error}` : ""}`, 0);
|
|
23582
|
+
}
|
|
23583
|
+
printProtocolResult(profile.output, importFields(finished));
|
|
23584
|
+
});
|
|
23585
|
+
}
|
|
23586
|
+
|
|
23387
23587
|
// src/commands/protocol/logs-follow.ts
|
|
23388
23588
|
var DEFAULT_BACKLOG = 10;
|
|
23389
23589
|
var DEFAULT_INTERVAL_SECONDS = 3;
|
|
@@ -23737,9 +23937,6 @@ function attachResourceDirectoryCommands(group, config) {
|
|
|
23737
23937
|
}
|
|
23738
23938
|
|
|
23739
23939
|
// src/commands/protocol/tables-import.ts
|
|
23740
|
-
import { setTimeout as sleep2 } from "node:timers/promises";
|
|
23741
|
-
var IMPORT_POLL_MS = 1500;
|
|
23742
|
-
var IMPORT_SETTLED = new Set(["completed", "failed", "canceled", "expired"]);
|
|
23743
23940
|
function tableNameFrom(fileName) {
|
|
23744
23941
|
const stem = fileName.replace(/\.[^.]+$/, "");
|
|
23745
23942
|
const cleaned = stem.replace(/[^A-Za-z0-9]+/g, "_").replace(/^_+|_+$/g, "");
|
|
@@ -23762,7 +23959,7 @@ function rejectionFields(job) {
|
|
|
23762
23959
|
...samples.length > 0 ? { rejectedSamples: samples } : {}
|
|
23763
23960
|
};
|
|
23764
23961
|
}
|
|
23765
|
-
function
|
|
23962
|
+
function progressLine2(job) {
|
|
23766
23963
|
const rows = job.rowsRejected ?? 0;
|
|
23767
23964
|
const cells = job.cellsRejected ?? 0;
|
|
23768
23965
|
const parts = [];
|
|
@@ -23773,26 +23970,6 @@ function progressLine(job) {
|
|
|
23773
23970
|
const suffix = parts.length > 0 ? `, ${parts.join(", ")}` : "";
|
|
23774
23971
|
return `${job.status}… ${job.rowsProcessed} rows${suffix}`;
|
|
23775
23972
|
}
|
|
23776
|
-
async function watchImport(client, workspaceId, job) {
|
|
23777
|
-
let current = job;
|
|
23778
|
-
let reported = null;
|
|
23779
|
-
while (!IMPORT_SETTLED.has(current.status)) {
|
|
23780
|
-
await sleep2(IMPORT_POLL_MS);
|
|
23781
|
-
const next = await client.request("getTableImport", {
|
|
23782
|
-
params: { importId: current.id },
|
|
23783
|
-
query: { workspaceId }
|
|
23784
|
-
});
|
|
23785
|
-
current = next.data;
|
|
23786
|
-
const line = progressLine(current);
|
|
23787
|
-
if (hasProgressTerminal() && line !== reported) {
|
|
23788
|
-
reported = line;
|
|
23789
|
-
writeStderr(`\r${styles3().dim(line)}\x1B[K`);
|
|
23790
|
-
}
|
|
23791
|
-
}
|
|
23792
|
-
if (hasProgressTerminal() && reported !== null)
|
|
23793
|
-
writeStderr("\r\x1B[K");
|
|
23794
|
-
return current;
|
|
23795
|
-
}
|
|
23796
23973
|
function validateTargetOptions(options) {
|
|
23797
23974
|
const intoExisting = Boolean(options.tableId);
|
|
23798
23975
|
const misplaced = intoExisting ? [
|
|
@@ -23887,7 +24064,10 @@ function attachTableImport(tables) {
|
|
|
23887
24064
|
});
|
|
23888
24065
|
return;
|
|
23889
24066
|
}
|
|
23890
|
-
const finished = await watchImport(
|
|
24067
|
+
const finished = await watchImport(job, async (current) => (await client.request("getTableImport", {
|
|
24068
|
+
params: { importId: current.id },
|
|
24069
|
+
query: { workspaceId }
|
|
24070
|
+
})).data, progressLine2);
|
|
23891
24071
|
if (finished.status !== "completed") {
|
|
23892
24072
|
throw new SimApiError(`Import ${finished.status}${finished.error ? `: ${finished.error}` : ""}`, 0);
|
|
23893
24073
|
}
|
|
@@ -24464,6 +24644,7 @@ function attachProtocolCommands(program) {
|
|
|
24464
24644
|
const knowledge = group(program, "knowledge");
|
|
24465
24645
|
attachKnowledgeDocumentUpload(group(knowledge, "documents"));
|
|
24466
24646
|
attachKnowledgeExport(knowledge);
|
|
24647
|
+
attachKnowledgeImport(knowledge);
|
|
24467
24648
|
attachResourceDirectoryCommands(knowledge, {
|
|
24468
24649
|
kind: "knowledge",
|
|
24469
24650
|
resources: "listKnowledgeBases",
|
|
@@ -26040,6 +26221,7 @@ Examples:
|
|
|
26040
26221
|
$ sim workflows export 3a9e21d8-5f47-4c0b-b2ea-91d7c6034ef8 > wf.json
|
|
26041
26222
|
$ sim workflows import --workflow @wf.json
|
|
26042
26223
|
$ sim knowledge export 4c1b7f60-2d55-4a3e-9c18-70b6ea2f9d31 -o ./kb.simkb.zip
|
|
26224
|
+
$ sim knowledge import ./kb.simkb.zip --name "Docs (copy)"
|
|
26043
26225
|
$ sim whoami --profile dev
|
|
26044
26226
|
`;
|
|
26045
26227
|
var AGENT_DISCOVERY_NOTE = `=== AGENT COMMAND DISCOVERY ===
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Polls an import until it settles, redrawing one progress line on stderr when
|
|
3
|
+
* it is a terminal and clearing it once the import is done.
|
|
4
|
+
*/
|
|
5
|
+
export declare function watchImport<T extends {
|
|
6
|
+
status: string;
|
|
7
|
+
}>(job: T, fetchNext: (current: T) => Promise<T>, progressLine: (current: T) => string): Promise<T>;
|