git-workspace-service 0.3.1 → 0.3.3
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/dist/index.cjs +29 -40
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -2
- package/dist/index.d.ts +9 -2
- package/dist/index.js +29 -40
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -324,19 +324,19 @@ var WorkspaceService = class {
|
|
|
324
324
|
credential = parent.credential;
|
|
325
325
|
} else {
|
|
326
326
|
await fs3__namespace.mkdir(workspacePath, { recursive: true });
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
}
|
|
327
|
+
credential = await this.credentialService.getCredentials({
|
|
328
|
+
repo: config.repo,
|
|
329
|
+
access: "write",
|
|
330
|
+
context: {
|
|
331
|
+
executionId: config.execution.id,
|
|
332
|
+
taskId: config.task.id,
|
|
333
|
+
userId: config.user?.id,
|
|
334
|
+
reason: `Workspace for ${config.task.role} in ${config.execution.patternName}`
|
|
335
|
+
},
|
|
336
|
+
userProvided: config.userCredentials,
|
|
337
|
+
// If no userCredentials provided, allow returning null for public repos
|
|
338
|
+
optional: !config.userCredentials
|
|
339
|
+
});
|
|
340
340
|
if (credential) {
|
|
341
341
|
await this.emitEvent({
|
|
342
342
|
type: "credential:granted",
|
|
@@ -361,8 +361,8 @@ var WorkspaceService = class {
|
|
|
361
361
|
path: workspacePath,
|
|
362
362
|
repo: config.repo,
|
|
363
363
|
branch: branchInfo,
|
|
364
|
-
credential,
|
|
365
|
-
//
|
|
364
|
+
credential: credential ?? void 0,
|
|
365
|
+
// Optional for public repos
|
|
366
366
|
provisionedAt: /* @__PURE__ */ new Date(),
|
|
367
367
|
status: "provisioning",
|
|
368
368
|
strategy,
|
|
@@ -381,32 +381,11 @@ var WorkspaceService = class {
|
|
|
381
381
|
if (!credential) {
|
|
382
382
|
const cloneResult = await this.tryUnauthenticatedClone(workspace);
|
|
383
383
|
if (!cloneResult.success) {
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
{ workspaceId, error: cloneResult.error },
|
|
387
|
-
"Unauthenticated clone failed, requesting credentials"
|
|
384
|
+
throw new Error(
|
|
385
|
+
`Repository ${config.repo} requires authentication but no credentials are available. Please provide credentials or configure OAuth.`
|
|
388
386
|
);
|
|
389
|
-
credential = await this.credentialService.getCredentials({
|
|
390
|
-
repo: config.repo,
|
|
391
|
-
access: "write",
|
|
392
|
-
context: {
|
|
393
|
-
executionId: config.execution.id,
|
|
394
|
-
taskId: config.task.id,
|
|
395
|
-
userId: config.user?.id,
|
|
396
|
-
reason: `Workspace for ${config.task.role} in ${config.execution.patternName}`
|
|
397
|
-
}
|
|
398
|
-
});
|
|
399
|
-
workspace.credential = credential;
|
|
400
|
-
this.workspaces.set(workspaceId, workspace);
|
|
401
|
-
await this.emitEvent({
|
|
402
|
-
type: "credential:granted",
|
|
403
|
-
workspaceId,
|
|
404
|
-
credentialId: credential.id,
|
|
405
|
-
executionId: config.execution.id,
|
|
406
|
-
timestamp: /* @__PURE__ */ new Date()
|
|
407
|
-
});
|
|
408
|
-
await this.cloneRepo(workspace, credential.token);
|
|
409
387
|
}
|
|
388
|
+
this.log("info", { workspaceId }, "Cloned public repository without authentication");
|
|
410
389
|
} else {
|
|
411
390
|
await this.cloneRepo(workspace, credential.token);
|
|
412
391
|
}
|
|
@@ -1360,7 +1339,9 @@ var CredentialService = class {
|
|
|
1360
1339
|
return this.providers.get(name);
|
|
1361
1340
|
}
|
|
1362
1341
|
/**
|
|
1363
|
-
* Request credentials for a repository
|
|
1342
|
+
* Request credentials for a repository.
|
|
1343
|
+
* If request.optional is true, returns null when no credentials available.
|
|
1344
|
+
* Otherwise throws an error.
|
|
1364
1345
|
*/
|
|
1365
1346
|
async getCredentials(request) {
|
|
1366
1347
|
const provider = this.detectProvider(request.repo);
|
|
@@ -1408,6 +1389,14 @@ var CredentialService = class {
|
|
|
1408
1389
|
credential = await this.getOAuthCredentialViaDeviceFlow(provider, request, ttlSeconds);
|
|
1409
1390
|
}
|
|
1410
1391
|
if (!credential) {
|
|
1392
|
+
if (request.optional) {
|
|
1393
|
+
this.log(
|
|
1394
|
+
"info",
|
|
1395
|
+
{ repo: request.repo },
|
|
1396
|
+
"No credentials available (optional request, returning null)"
|
|
1397
|
+
);
|
|
1398
|
+
return null;
|
|
1399
|
+
}
|
|
1411
1400
|
throw new Error(
|
|
1412
1401
|
`No credentials available for repository: ${request.repo}. ` + (this.oauthConfig ? "OAuth device flow failed or was cancelled." : "Configure OAuth to enable interactive authentication.")
|
|
1413
1402
|
);
|